Vue+Webpack常見問題(持續更新)


常識

1.computed計算屬性,使用的屬性必需在data里面聲明。

computed: {
    canLogin: function(){
        //注意這里的依賴的屬性必需在data里面聲明
        return this.name && this.password;
    }
}

Webpack問題

1.模塊里面使用JSON.stringify和 typeof,報:Uncaught TypeError: Cannot assign to read only property 'exports' of #<Object>

解決方法:把.babelrc里的plugin "transform-runtime" 刪掉, 重啟運行 

Vue控件問題

1.VueI18n的messages設置無效問題

//messages得單獨寫出來,不然會報[vue-i18n] Cannot translate the value of keypath “”. Use the value of keypath as default.
const messages = {
  'lang': path.i18n
}
const i18n = new VueI18n({
    locale: 'lang',
    messages
})

new Vue({
    .....
    i18n
})

 


免責聲明!

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



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