1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > vue.js项目中 关于element-ui完整引入 按需引入的介绍

vue.js项目中 关于element-ui完整引入 按需引入的介绍

时间:2021-04-23 13:00:53

相关推荐

vue.js项目中 关于element-ui完整引入 按需引入的介绍

element-ui引入方式,简单说来有两种:完整引入按需引入

首先谈一下npm安装element-ui的方法:
cmd到项目目录,然后执行cmd命令:npm i element-ui -S稍等片刻,这样就安装OK了。

[起初node_modules在单项目文件内],其实后面完全可以剔出来,方便多个项目公共使用!

下面就这两种方式,简单说一下如何操作,详细请参考官网相关文档

1. 完整引入

import Element from 'element-ui';//样式文件,需单独引入import 'element-ui/lib/theme-chalk/index.css';

对应的代码,如下:

Vue.use(Element, {size: 'small' });

属性size取值 (small ,big ,) ,决定组件尺寸的大小。

2. 按需引入

import {Pagination,Dialog,···省略···Footer,Loading,MessageBox,Message,Notification} from 'element-ui';//样式文件,需单独引入import 'element-ui/lib/theme-chalk/index.css';

对应的代码,如下:

Vue.use(Pagination);Vue.use(Dialog);···省略···Vue.use(Footer);Vue.use(Loading.directive);Vue.prototype.$loading = Loading.service;Vue.prototype.$msgbox = MessageBox;Vue.prototype.$alert = MessageBox.alert;Vue.prototype.$confirm = MessageBox.confirm;Vue.prototype.$prompt = MessageBox.prompt;Vue.prototype.$notify = Notification;Vue.prototype.$message = Message;

以上就是关于“vue.js项目中,关于element-ui完整引入、按需引入的介绍”的全部内容。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。