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