vue-cli3中引入ant-vue时的less依赖报错

修改babel.config.js文件后报错;

​
module.exports = {
  presets: [
   '@vue/app',
  ],
  // 配置babel-plugin-import, 用于按需加载组件代码和样式
  plugins: [
    [
      "import",
      { libraryName: "ant-design-vue", libraryDirectory: "es", style: true }
    ]
  ],
}

​

解决方法:1.配置vue.config.js,在根目录下新建vue.config.js

        

module.exports = {
    // 配置less
    css: {
        loaderOptions: {
            less: {
                javascriptEnabled: true,
            }
        }
    },
}

2.修改babel.config.js

plugins: [
    [
      "import",
      { libraryName: "ant-design-vue", libraryDirectory: "es", style: 'css' }
    ]
  ]

3.npm run serve

你可能感兴趣的:(vue-cli3中引入ant-vue时的less依赖报错)