当前位置: 首页 > wzjs >正文

重庆市建设领域农民工工资专户网站聚合搜索引擎入口

重庆市建设领域农民工工资专户网站,聚合搜索引擎入口,做网站专业的公司,wordpress密码_目录 1 安装2 引入2.1 全局引入2.1.1 引入2.1.2 使用 2.2 按需引入2.2.1 引入2.2.2 使用 3 总结 1 安装 推荐使用 npm 的方式安装,它能更好地和 webpack打包工具配合使用。(本项目使用安装方式) npm i element-ui -S也可以使用其他的包管理…

目录

      • 1 安装
      • 2 引入
        • 2.1 全局引入
          • 2.1.1 引入
          • 2.1.2 使用
        • 2.2 按需引入
          • 2.2.1 引入
          • 2.2.2 使用
      • 3 总结

1 安装

推荐使用 npm 的方式安装,它能更好地和 webpack打包工具配合使用。(本项目使用安装方式)

npm i element-ui -S

也可以使用其他的包管理起进行安装:

# Yarn
$ yarn add element-ui# pnpm
$ pnpm install element-ui

2 引入

ElementUI分为全局引入和按需引入两种方式,一般在工程项目中,如果使用全局引入,则项目初始化时会导致不必要的资源加载,为提升项目性能,建议进行按需引入。以下我们对两种引入方式进行介绍。

2.1 全局引入
2.1.1 引入

在 main.js 中写入以下内容:

import Vue from 'vue';
import ElementUI from 'element-ui';
//样式文件需要单独引入
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue';Vue.use(ElementUI);new Vue({el: '#app',render: h => h(App)
});

以上代码便完成了 Element 的引入。

2.1.2 使用

引入完成之后就可以使用组件了,如下示例为使用container组件和button组件:

效果如下:
在这里插入图片描述

代码如下:

<template><el-container><el-header>Header</el-header><el-container><el-aside width="200px">Aside</el-aside><el-container><el-main>Main<el-button type="primary">按钮</el-button></el-main><el-footer>Footer</el-footer></el-container></el-container></el-container>
</template>
<script>
export default {};
</script>
<style scoped>
.el-header,
.el-footer {background-color: #b3c0d1;color: #333;text-align: center;line-height: 60px;
}.el-aside {background-color: #d3dce6;color: #333;text-align: center;line-height: 200px;
}.el-main {background-color: #e9eef3;color: #333;text-align: center;line-height: 160px;
}body > .el-container {margin-bottom: 40px;
}.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {line-height: 260px;
}.el-container:nth-child(7) .el-aside {line-height: 320px;
}
</style>
2.2 按需引入

可以使用babel-plugin-component这个Babel插件。这样,你可以只引入你实际使用的组件和它们的样式,从而减小项目体积和构建时间。

2.2.1 引入

首先,安装 babel-plugin-component:

npm install babel-plugin-component -D

然后,将 .babelrc 或者babel.config.js文件修改为:

{"presets": [["es2015", { "modules": false }]],"plugins": [["component",{"libraryName": "element-ui","styleLibraryName": "theme-chalk"}]]
}
2.2.2 使用

若想实现上图效果,按需引入时需要将使用的所有组件都引入进来,代码如下:

<template><el-container><el-header>Header</el-header><el-container><el-aside width="200px">Aside</el-aside><el-container><el-main>Main<el-button type="primary">按钮</el-button></el-main><el-footer>Footer</el-footer></el-container></el-container></el-container>
</template>
<script>
import Vue from "vue";
import { Button, Container, Header, Aside, Main, Footer } from "element-ui";
Vue.use(Button);
Vue.use(Container);
Vue.use(Aside);
Vue.use(Main);
Vue.use(Footer);
Vue.use(Header);export default {};
</script>
<style scoped>
.el-header,
.el-footer {background-color: #b3c0d1;color: #333;text-align: center;line-height: 60px;
}.el-aside {background-color: #d3dce6;color: #333;text-align: center;line-height: 200px;
}.el-main {background-color: #e9eef3;color: #333;text-align: center;line-height: 160px;
}body > .el-container {margin-bottom: 40px;
}.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {line-height: 260px;
}.el-container:nth-child(7) .el-aside {line-height: 320px;
}
</style>

按需引入组件,组件全部名称详见官网;

3 总结

通常情况下,若是对性能没有要求时,可以使用全局导入方式引入所有组件,若对页面加载性能有要求,则最好使用按需加载方式引入组件,以防多余的资源加载增加页面初始化耗时。

http://www.dtcms.com/wzjs/31724.html

相关文章:

  • 做网站需要什么代码广东最新疫情
  • 58同城深圳网站建设如何写软文
  • http网站开发关键词优化到首页怎么做到的
  • 入门做网站seo优化或网站编辑
  • 西安知名的集团门户网站建设企业北京刚刚传来特大消息
  • 和县网站制作十大营销策划公司排名
  • wordpress flashfxpseo海外推广
  • 手机网站开发软文广告范例大全
  • 合川区城乡建设委员会网站百度如何搜索网址
  • 购物网站怎么做项目简介百度首页优化排名
  • 网站做镜像的有什么用无锡百度正规公司
  • 如何看网站是html几代做的杭州seo网站推广
  • wordpress 新建文件对网站外部的搜索引擎优化
  • 工程信息建程网单页网站seo优化
  • 青岛市做网站优化seo技术优化技巧
  • asp做的网站如何发布seo优化网站查询
  • 上传网站到百度百度搜索优化怎么做
  • 做企业网站的尺寸是多少钱网络营销方式有哪些分类
  • 新疆生产建设兵团供销社网站seo综合查询 站长工具
  • 网站建设开发费用网络推广服务外包公司
  • 做外贸网站费用2022年新闻摘抄十条
  • 自建网上商城seo网站推广助理
  • 光谷网站建设宁波优化网站厂家
  • 网站建设策划书选题武汉做seo公司
  • 江西省住房和城乡建设厅网站市场调研报告800字
  • 济南网站自然优化百度百家号官网登录
  • 企业网站建设的基本原则网站维护公司
  • 视频网站搭建黄页推广引流
  • 四川省人民政府文史研究馆网络关键词优化方法
  • 在线商城网站建设优秀网页设计公司