var app = new Vue({
el: '#app',
data: function() {
return {
// count: 100
}
},
components: ['counts']
});
Vue.component('counts', {
template: '<h2>{{counts.count}}</h2>',
data: function (){
return {
count: 100
}
},
methods: {
minus: function() {
this.count -= 1;
}
},
mounted() {
var Timer = null;
Timer = setInterval(function() {
this.minus()
if (this.count <= 0) {
clearInterval(Timer);
}
}, 50);
}
});
<div id="app">
<counts></counts>
</div>