Parsing error: Unexpected token < at ... Vue CLI3


在使用vue cli3的时候,遇到如下问题:

error: Parsing error: Unexpected token < at src\views\index.vue:1:1:
> 1 | <template>
    | ^
  2 |   <div class="index">
  3 |     <router-view></router-view>
  4 |     <TabBar :data="tabbarData"></TabBar>

 

查阅了许多网站,都不能解决此问题,最后,在 

https://stackoverflow.com/questions/53601579/parsing-error-unexpected-token-using-vuecli3-and-airbnb-eslint?r=SearchResults

找到了办法

打开你的   .eslintrc.js 文件,找到 parser

这是我的  .eslintrc.js 

module.exports = {
    rules: {
        'no-console': 'off',
        "parser": "vue-eslint-parser"
    },
}

 

 

注意:

  当我写入 import 时,就会报上述错误,这个时候,只需要把 .eslintrc.js 里的 

"parser": "vue-eslint-parser" 注释掉,重新启动项目。然后,取消掉注释,再次重启项目,就没有报错了。

为什么会这样,我也不理解。如果你们有了更好的解决办法,麻烦给我留言,谢谢!!!


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM