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);
},
小程序未退出,我每按一次关机键在看小程序,弹窗连续显示就会增加一个(原本只会显示一个),为什么?