<view class="show">
<view class="btn" @click="goIndex">
{{count}}s 跳过
</view>
</view>
data() {
return {
count: 3,
timer: null,
}
},
onShow() {
let that = this;
that.countDown()
},
methods: {
countDown() {
let that = this;
const TIME_COUNT = 3;
if (!that.timer) {
that.count = TIME_COUNT;
that.timer = setInterval(() => {
if (that.count > 0 && that.count <= TIME_COUNT) {
that.count--;
} else {
clearInterval(that.timer);
that.timer = null;
uni.navigateTo({
url: './index'
})
}
}, 1000);
}
},
goIndex() {
let that = this;
clearInterval(that.timer);
that.timer = null;
uni.navigateTo({
url: './index'
})
}
}
uni小程序首页计时器
最新推荐文章于 2024-06-17 22:05:08 发布