vue中 this失效

参考:Vue 回调函数中this无效

1、在回调函数之前将 vue 实例 this 赋值给一个变量,在回调函数中使用该变量

equestHistoryList (mobileNumber, channelIndex) {
    ......
    var _that = this
    this.sendCommand(url, params,function (ret) {
          console.log(_that)
          if (ret.code == 0) {
            if (ret.data.sendResult == "SUCCESS") {
                  var parse = JSON.parse(ret.data.params);
                  _that.playBackVideoList = parse.infos
                  console.log(_that.playBackVideoList)
            }
          }else {
            alert(ret.msg);
          }
    })
},

 

posted @ 2022-07-19 17:02  BBS_自律  阅读(247)  评论(0)    收藏  举报