問題場景:
form表單中checkbox的增刪改查,在后台獲取到的數據中拿到checkbox的值,但是改不了狀態,是因為在后台拿到的form表單的數據和重置數據出現沖突
錯誤:
async getDetail () {
await this.$api.getTaskDetail({
params: {
id: this.id
}
}).then(res => {
this.form = res,
this.form.checkbox = res.email_enbale == '1'? true: false
})
},
正確:
async getDetail () { await this.$api.getTaskDetail({ params: { id: this.id } }).then(res => { this.form = { ...res, checkbox: res.email_enbale == '1'? true: false } }) },
