Vue 'data' 選項
定義和用法
data
選項是一個返回包含所有資料屬性的物件的方法。
由 data
方法返回的物件可以透過 this.$data
訪問,特定的資料屬性 'count' 可以透過 this.$data.count
或簡單地透過 this.count
訪問。
以 $
或 _
開頭的資料屬性必須透過 this.$data
物件訪問,否則無法訪問。
在應用程式開始執行後,可以透過使用 this.$data
來新增新的資料屬性,但不推薦這樣做。
相關頁面
Vue 教程:Vue 簡介
Vue 參考:Vue $data 物件