问题场景:
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 } }) },