在Vue項目中使用Element UI:按需引入和完整引入


下面操作在main.js文件中進行

完整引入:

import Element from 'element-ui';

//樣式文件,需單獨引入

import 'element-ui/lib/theme-chalk/index.css';
//在引入前需要npm安裝element-ui
Vue.use(Element, { size: 'small' });

屬性size取值 ( small ,big , ) ,決定組件尺寸的大小。

按需引入:

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;

轉自:https://blog.csdn.net/qq_35393869/article/details/80351487 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM