2019-08-21-vue报错 + TypeError: _vm.model is undefined

报错截图:

2019-08-21-vue报错 + TypeError: _vm.model is undefined_第1张图片
image.png

代码如下:

//.... 
created () {
    // this.model.user_id = this.userId
    this.fetchDetail()
  },
  methods: {
    async fetchDetail () {
      let res = await fetchStaffBaseDetail({ id: this.basicForm.user_id })
      if (res.success) {
        this.basicForm = res.data.set
      }
    },
// ......
}

原因是,**fetchStaffBaseDetail({ id: ... }) ** 返回的数据是非对象引发的。

返回的响应数据格式:

{"success":true,"data":false}

添加判断,以上情况不再进行赋值:

 async fetchDetail () {
      let res = await fetchStaffBaseDetail({ id: this.basicForm.user_id })
      if (res.success && res.data !== false) {
        this.basicForm = res.data.set
      }
    }

你可能感兴趣的:(2019-08-21-vue报错 + TypeError: _vm.model is undefined)