1.需要用到两个API分别是wx.showTabBarRedDot()和wx.hideTabBarRedDot
wx.showTabBarRedDot() 显示 tabBar 某一项的右上角的红点
wx.hideTabBarRedDot 隐藏 tabBar 某一项的右上角的红点
index tabBar 的哪一项,从左边算起
2.需要用到定时器setInterval()
思路:我们用定时器控制红点的显示和隐藏就可以了!
具体如下:
data:{
countDownNum: 100,
i: 123,
},
//设置定时器
countDown: function () {
var that = this,
countDownNum = that.data.countDownNum
if (that.data.i != null) {
that.setData({
timer: setInterval(function () {
countDownNum--;
console.log(countDownNum)
//当countDownNum为偶数时显示红点
//当countDownNum为奇数时隐藏红点
if (countDownNum %