前些天發現了一個巨牛的人工智能學習網站,通俗易懂,風趣幽默,忍不住分享一下給大家。點擊跳轉到教程。
1. 只是想定義一個變量,方便頁面上調用 。
報錯:
The "data" option should be a function that returns a per-instance
value in component definitions.Property or method "seen" is not defined on the instance but referenced
during render. Make sure that this property is reactive, either in the data option,
or for class-based components, by initializing the property. See:
https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.
我的原寫法:
data: {A: false,B: true}
?2. 原因:
“ 一個組件的?data
?選項必須是一個函數,因此每個實例可以維護一份被返回對象的獨立的拷貝。”
這句話出自 :
?
3. 修改 ,改為:
data: function() {return {seen: true};
},
?再運行,OK了。