在資料函式中,我用今天的日期創建了明天的變數,然后我通過附加 1 天來設定它,但我收到了這個錯誤
data(){
return{
tomorrow: new Date(),
tomorrow.setDate(tomorrow.getDate() 1),
};
},
錯誤決議錯誤:意外標記。
uj5u.com熱心網友回復:
data 屬性是為存盤變數而設計的,而不是像您嘗試那樣呼叫函式或添加邏輯。
嘗試計算屬性:
computed: {
tomorrow() {
const d = new Date()
d.setDate(d.getDate() 1)
return d
}
}
然后在你的模板中你可以做{{ tomorrow }}或在你的 vue 組件中this.tomorrow
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/377656.html
