赞
踩
<view>{{ count }}s后自动返回</view>
export default { data() { return { // 秒数 count: 3, // 计时器 timer: null, }; }, onShow() { this.countDown(); }, methods: { // 计时 countDown() { let time_count = 3; 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; // 倒计时完成后do something ... } }, 1000); } }, }, }; </script>
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。