怎么会报这样的错误??
发布于 7 年前 作者 jing35 3918 次浏览 来自 问答

  goPlay: function (e) {

    var that = this;

    that.setData({

      audioIndex: e.target.dataset.current

    })

    wx.getBackgroundAudioPlayerState({

      success: function (res) {

        var status = res.status

        var dataUrl = res.dataUrl

        if (status == “0” || dataUrl != that.data.audioList.tracks.list[e.target.dataset.current].playPathAacv164){

          that.playAudio(e.target.dataset.current);

        }else{

          wx.pauseBackgroundAudio();

          that.setData({

            audioIndex: -1

          })

        }

      },

      fail:function (){

        that.playAudio(e.target.dataset.current);

      }

    })

  },

  playAudio:function(index){

    wx.playBackgroundAudio({

      dataUrl: that.data.audioList.tracks.list[index].playPathAacv164,

      title: that.data.audioList.tracks.list[index].title,

      coverImgUrl: that.data.audioList.tracks.list[index].smallLogo

    })

  },

这是什么问题

1 回复

playAudio:function里没有定义that呀,加一句var that=this就行了。

回到顶部