vue做30s倒计时,在最后10s的时候有个放大的效果
// 请把代码文本粘贴到下方(请勿用图片代替代码)
<template>
<div>
<p>{{second}}</p></div>
</template>
<script >
export default {
data () { return { seconds: 30
}
},
mounted () { this.add()
},methods: { num: function (n) { return n < 10 ? '0' + n : '' + n
}, add: function () { var _this = this
var time = window.setInterval(function () { if (_this.seconds === 0 ) {
_this.seconds = 0
} else if ( _this.seconds === 0) {
_this.seconds = 0
window.clearInterval(time)
} else {
_this.seconds -= 1
}
}, 1000)
}
},computed: { second: function () { return this.num(this.seconds)
},
}}
</script>
慕田峪7331174
相关分类