vue-router component: () => imp
作者:
林间树洞 | 来源:发表于
2020-04-15 11:30 被阅读0次
npm run dev控制台直接报错:
Module build failed: SyntaxError: Unexpected token
是import报错了,需要babel的插件,vue-router官网上提示:
如果您使用的是 Babel,将需要添加 syntax-dynamic-import 插件,才能使 Babel 可以正确地解析语法。
如果使用vue-cli生成项目,很可能在babel-loader没有配置上面的插件,这时需要我们自己去安装此插件:
cnpm install babel-plugin-syntax-dynamic-import --save-dev
使用此插件需要在.babelrc文件加入:
{ "plugins": ["syntax-dynamic-import"]}
本文标题:vue-router component: () => imp
本文链接:https://www.haomeiwen.com/subject/umtrvhtx.html
网友评论