<div id="app">
{{count}}
<button @click="count++">点击加一</button>
</div>
<script>
new Vue({
el: "#app",
data: {
count: 1
},
watch: {
count: function(val) {
var that = this;
window.setTimeout(function() {
that.count = 0;
},2000)
}
}
})
</script>
vue当watch监听到count值发生变化时,2秒之后归零
最新推荐文章于 2022-11-15 10:04:58 发布