收藏
回答

微信同声传译onStop事件中this.函数名()不能调用?

var plugin = requirePlugin("WechatSI")

let manager = plugin.getRecordRecognitionManager()

manager.onStop = function (res) {

      wx.showToast({

        title: res.result,

      })

     this.setData({yuyin:res.result})

this.wordYun()

}    

所以和this相关的都是报错;错误提示:this.setData is not a function;也用var that=this测试,同样报错

回答关注问题邀请回答
收藏

2 个回答

  • 风清雾云开见日出
    风清雾云开见日出
    2021-07-22

    前面加一个let that= this,后面用that调用

    2021-07-22
    有用
    回复
  • xplee
    xplee
    2021-07-21

    用事件触发试试吧。

    manager.onStop = function (res) {
        wx.showToast({
         title: res.result,
       })
      this.triggerEvent('onMyEvent', { yuyin : res.result } )
      this.wordYun()
    }
    function onMyEvent(event) {
      var yuyin = event.detail.yuyin
    
      this.setData({
        yuyin:yuyin
      })
    }
    
    2021-07-21
    有用
    回复
登录 后发表内容