问题总结 elementUI el-checkbox 无法勾选问题

问题场景:

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
        }
      })
    },

 

posted @ 2019-09-19 20:20  maomao^_^  阅读(13928)  评论(0)    收藏  举报