出现一个TypeError错误

出现了一个TypeError: this.$api.device.saveAndUpdate is not a function  在创建

     handleEdit(id){

          let params = this.id 

                this.$api.device.saveAndUpdate(id).then((res)=>{

                    this.getAlarmDevices()

                })  

        },

时候,这是调用的后台的一个方法,方法中写了一个查询,增加和删除

this的指向出现了问题

 

handleEdit(id){
          const _this = this
          let params = this.id 

                _this.$api.device.saveAndUpdate(id).then((res)=>{
                _this.getAlarmDevices()

                })  

        },