Vue引用Element UI时的配置

babel.config.js

module.exports = {
  presets: [
    ‘@vue/cli-plugin-babel/preset‘,
    ["@babel/preset-env", { "modules": false }]
  ],
  "plugins": [
    [
      "component",
      {
        "libraryName": "element-ui",
        "styleLibraryName": "theme-chalk"
      }
    ]
  ]
}

main.js (组件全部引入)

import Vue from ‘vue‘
import App from ‘./App.vue‘
import ElementUI from ‘element-ui‘;
import ‘element-ui/lib/theme-chalk/index.css‘;

Vue.config.productionTip = false

Vue.use(ElementUI);

new Vue({
  render: h => h(App),
}).$mount(‘#app‘)

main.js (组件部分引入)

import Vue from ‘vue‘;
import App from ‘./App.vue‘;
import { Button, Select } from ‘element-ui‘;

Vue.config.productionTip = false

Vue.component(Button.name, Button);
Vue.component(Select.name, Select);
/* 或写为
 * Vue.use(Button)
 * Vue.use(Select)
 */

new Vue({
  el: ‘#app‘,
  render: h => h(App)
});

Vue引用Element UI时的配置

上一篇:使用多线程改进flask项目案例


下一篇:安装qt_vs_tools遇到的各种问题