美文网首页前端
vue-router component: () => imp

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"]}

相关文章

  • router的创建

    import Vue from 'vue' import Router from 'vue-router' imp...

  • Vue报错原因and解决办法

    1、Uncaught Error: [vue-router] route config "component" f...

  • React Native常用组件之ListView创建九宫格

    还是老规矩将要使用的控件引入进来 importReact, {Component}from'react'; imp...

  • vue-router component: () => impo

    npm run dev控制台直接报错: 是import报错了,需要babel的插件,vue-router官网上提示...

  • Vue-Router

    Vue-Router路由 1路由基础 创建一个路由对象数组,每个对象分别有,path,component等属性,在...

  • 2019-07-31 vue-router component

    1、安装vue-cli脚手架 a.下载安装node.js,随包同时也安装了npm;b.安装vue-cli:npm ...

  • - (IMP)methodForSelector与+ (IMP)

    浮于表面探究问题不失为一种方法,但是弄清楚本质才是真正意义上的解决疑惑。 之前已经写过一篇博客- (IMP)met...

  • - (IMP)methodForSelector与+ (IMP)

    导语 今天在编码的时候,无意间看到了- (IMP)methodForSelector函数,让我联想到平时经常用的+...

  • IMP

    IMP定义在runtime的objc.h中,定义如下: typedef说明形式:typedef 返回类型(新类型...

  • IMP

    IMPTest声明方法 新建IMPTest类,创建方法 ViewController调用方法 结果输出

网友评论

    本文标题:vue-router component: () => imp

    本文链接:https://www.haomeiwen.com/subject/umtrvhtx.html