Vue-使用中報錯處理ERROR

Vue常見錯誤解析

vue.js:634 [Vue warn]: Do not mount Vue to <html> or <body> - mount to normal elements instead.

vue實例只能掛在到普通的元素標籤上,不能是html、body標籤,而且推薦使用id選擇器來獲取標籤

[Vue warn]: Property or method "XXX" is not defined on the instance but referenced during render.

vue框架是一個聲明式的框架,所以在掛載點內要使用變量時,要定義才能使用。

[Vue warn]: Unknown custom element: <mycom> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
組件的名字是否正確,或者檢查有沒有註冊

注意事項關於組件名稱:
vue.js:634 [Vue warn]: Do not use built-in or reserved HTML elements as component id: div
組件的名稱不能是html內置的標籤
組件的名稱不是html內置的標籤全大寫
如果組件的名稱包含大寫字母(非首字母),在使用組件時,要把大寫字母轉換成-小寫字母

vue.js:634 [Vue warn]: The "data" option should be a function that returns a per-instance value in component definitions.

因爲對象類型的數據影響,組件複用時,數據會相互影響,所以爲了保證數據的正確性和獨立性,在組件中定義data時,要寫成一個函數,並返回一個對象來定義組件的初始數據

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章