vue常見錯誤及解決辦法


  1、在配置路由並引入組件后,報錯:

    Unknown custom element: <router-link> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

  錯誤原因:vue-router沒有注冊

  解決辦法:

     //注冊插件 *****************非常重要,不能忘記
    Vue.use(VueRouter)
 
2、在組件中的標簽和樣式中圖片路徑出錯時:報錯:
    Errors while compiling. Reload prevented.
    Module not found: Error: Can't resolve './src/assets/img/btn_bg.png' in 'E:\myStudy\vue案例\chexian-spa\src\components'

  解決辦法:將圖片的路徑重新書寫

3、在組件中標簽沒有閉合,報錯:

     Errors while compiling. Reload prevented.

    ./node_modules/_vue-loader@13.4.0@vue-loader/lib/template-compiler?{"id":"data-v-00822b28","hasScoped":false,"buble":{"transforms":{}}}!./node_modules/_vue-loader@13.4.0@vue-loader/lib/selector.js?type=template&index=0&bustCache!./src/components/BaseProject.vue

 

(Emitted value instead of an instance of Error) 

  解決辦法:檢查html代碼

 4、在使用less定義變量是報錯:

  

  錯誤原因:必須用分號結尾:@imgUrl:'../../assets/img/';

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM