收藏
回答

这是定时器和手机关机键隐藏的bug吗?

问题模块
API和组件

showDanMu:function(num){

var that = this;

setInterval(function () {

var danmulist = that.data.danmulist;

if (danmulist && danmulist.length > 0) {

if (num == danmulist.length) {

num = 0;

that.setData({ showdanmu: true, danmuname:danmulist[num].msgame, danmuhead: danmulist[num].avatarUrl })

setTimeout(function () {

that.setData({ showdanmu: false })

},3000)


} else {

that.setData({ showdanmu: true, danmuname: danmulist[num].msg, danmuhead: danmulist[num].avatarUrl })

setTimeout(function () {

that.setData({ showdanmu: false })

},3000);

num++;

}

}

},5000)

},

onShow: function (e) {

var that=this;

var num=0;

// 调用弹幕

that.showDanMu(num);

},

小程序未退出,我每按一次关机键在看小程序,弹窗连续显示就会增加一个(原本只会显示一个),为什么?

最后一次编辑于  2017-12-20
回答关注问题邀请回答
收藏