xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

element-ui & babel-plugin-component config bug

vue-cli

bad ❌

babel.config.js

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

good ✅

babel.config.js

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


main.js


import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';

// import ElementUI from 'element-ui';
// import 'element-ui/lib/theme-chalk/index.css';
// Vue.use(ElementUI);

import { Button, Select } from 'element-ui';
// Vue.component(Button.name, Button);
// Vue.component(Select.name, Select);
/* OR */
Vue.use(Button);
Vue.use(Select);



Vue.config.productionTip = false;

new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app');

https://element.eleme.io/#/en-US/component/quickstart#on-demand

refs



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


原文地址:https://www.cnblogs.com/xgqfrms/p/14061169.html