开发者社区> 问答> 正文

在vue/cli3创建的项目中import()不能用?报错

使用vue/cli3创建的antdv项目,import() 动态引入不能用,报错如下

./src/router/index.js
Module Error (from ./node_modules/eslint-loader/index.js):
error: Parsing error: Unexpected token import at src/router/index.js:65:46:
  63 |                             path: 'juese',
  64 |                             name: 'juese',
> 65 |                             component: () => import('../pages/rbac/juese.vue')

我觉得我应该是少包,于是引入了 "babel-plugin-import": "^1.12.0", 然后能用了,然后又不能用了,我严重怀疑能用的是幻觉....

然后我不管怎么摆弄都不能用

当前我的包配置文件

 

{
  "name": "antd_admin",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build --no-clean",
    "lint": "vue-cli-service lint --fix"
  },
  "dependencies": {
    "ant-design-vue": "^1.4.10",
    "axios": "^0.19.0",
    "clipboard": "^2.0.4",
    "core-js": "^3.3.2",
    "jshashes": "^1.0.7",
    "lodash": "^4.17.15",
    "spms.socket": "^1.0.0",
    "vue": "^2.6.10",
    "vue-ls": "^3.2.1",
    "vue-router": "^3.1.3",
    "vuex": "^3.1.2"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^4.0.0",
    "@vue/cli-plugin-eslint": "^4.0.0",
    "@vue/cli-service": "^4.0.0",
    "babel-eslint": "^10.0.3",
    "babel-plugin-import": "^1.12.0",
    "eslint": "^5.16.0",
    "eslint-config-standard": "^14.1.0",
    "eslint-config-vue": "^2.0.2",
    "eslint-plugin-html": "^6.0.0",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-node": "^10.0.0",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-standard": "^4.0.1",
    "eslint-plugin-vue": "^5.0.0",
    "less": "^3.10.3",
    "less-loader": "^5.0.0",
    "vue-template-compiler": "^2.6.10"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "rules": {},
    "parserOptions": {
      "parser": "babel-eslint"
    }
  },
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions"
  ]
}

 

展开
收起
爱吃鱼的程序员 2020-06-05 14:41:58 1442 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB
                        <p>我重现了,我能用的瞬间,就是刚刚yarn完成后的第一次yarn server能用,然后就不能用了,我重启了电脑也是这样,,,,删除node_module 后重新yarn也是只能用一瞬间!</p>
    
    2020-06-05 14:42:12
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Vue.js 在前端服务化上的探索与实践 立即下载
利用编译将 Vue 组件转成 React 组件 立即下载
Vue.js在前端服务化上的实践与探索 立即下载