0

vue项目引入社区的ant-design-vue,根据其文档进行按需加载,如下图所示:

main.js

clipboard.png

import Vue from 'vue'
import Antd from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css'
import Vuex from 'vuex'
import App from './App'
import store from './store/index'
import router from './router'
import './utils/commonFunction/iconfont/iconfont.js'
import './utils/commonFunction/iconfont/iconfont.css'
import './assets/css/common.css'
import './assets/css/base.css'
import './assets/css/elementUiRe.css'

Vue.use(Antd)
Vue.use(Vuex)
Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})

.babelrc

clipboard.png

{
  "presets": [
    ["env", {
      "modules": false,
      "targets": {
        "browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
      }
    }],
    "stage-2"
  ],
  "plugins": [
    "transform-vue-jsx",
    ["import", {
      "libraryName": "ant-design-vue",
      "libraryDirectory": "es",
      "style": "css" }
    ],
    "transform-runtime"
  ],
  "env": {
    "test": {
      "presets": ["env"],
      "plugins": [
        "transform-vue-jsx",
        "transform-es2015-modules-commonjs",
        "dynamic-import-node",
        "transform-runtime"
      ]
    }
  }
}

package.json

clipboard.png

这里是我安装配置的地方,但是一旦启动项目,就报错

clipboard.png

请问应该怎么修改处理?

2018-09-17 提问

查看全部 3 个回答

1

名称不一致就找不到
全局引入的时候去掉 按需加载 也可以解决问题

clipboard.png

clipboard.png

推广链接