<view
class
=
"number"
>{{count}}</view>
<!-- 倒计时数字 -->
data() {
return
{
count: 30,
timer:
null
,
};
},
methods: {
countDown() {
let
_this =
this
;
const
TIME_COUNT = 30;
if
(!
this
.timer) {
this
.count = TIME_COUNT;
this
.timer = setInterval(() => {
if
(
this
.count > 0 &&
this
.count <= TIME_COUNT) {
this
.count--;
}
else
{
clearInterval(
this
.timer);
this
.timer =
null
;
}
}, 1000);
}
},
},
onShow() {
this
.countDown();
}