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

  1. module.exports = {
  2. presets: [
  3. '@vue/app',
  4. ],
  5. // 配置babel-plugin-import, 用于按需加载组件代码和样式
  6. plugins: [
  7. [
  8. "import",
  9. { libraryName: "ant-design-vue", libraryDirectory: "es", style: true }
  10. ]
  11. ],
  12. }

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

  1. module.exports = {
  2. // 配置less
  3. css: {
  4. loaderOptions: {
  5. less: {
  6. javascriptEnabled: true,
  7. }
  8. }
  9. },
  10. }

2.修改babel.config.js

  1. plugins: [
  2. [
  3. "import",
  4. { libraryName: "ant-design-vue", libraryDirectory: "es", style: 'css' }
  5. ]
  6. ]

3.npm run serve