十秒挑战小游戏
<div id="app">
<div class="box">
<p>{{num}}</p>
<button @click="btn">点击点击</button>
<button @click="btn2">暂停</button>
</div>
</div>
<script>
let vm = new Vue({
el: '#app',
data: {
num: '0.00',
addNum:'0.01',
time:null
},
methods: {
btn() {
this.time = setInterval(() => {
this.num = (Number(this.num) + Number(this.addNum)).toFixed(2)
}, 30)
},
btn2(){
clearInterval(this.time)
if(this.num=='10.00'){
alert('你真棒!!!')
window.location.reload()
}else{
alert('你真辣~~~')
window.location.reload()
}
}
}
})
</script>