<template>
<view class="">
限时优惠仅剩<text>{{ minute }}</text>分<text>{{ second }}</text>秒
</view>
</template>
data() {
return {
second:0,
minute:3
}
},
onShow() {
let that = this
//执行倒计时
setInterval(function(){
that.time()
}, 1000);
},
methods: {
time: function() {
if (this.minute > 0 && this.second == 0) {
this.minute-=1
this.second = 60
}
if (this.second > 0) {
this.second-=1
}
}
}