I need some help with my code. Please take a look at this link here. I want the input to count up from zero and hide when I click the "change" button. But when I show the input again, I want its value to reset back to zero. Can anyone guide me on how to achieve this?
<script src="//unpkg.com/vue/dist/vue.js"></script>
<div id="app">
<input :value="change" v-if="val1">
<br/>
<button @click="switchOn">Change</button>
</div>
var Main = {
data() {
return {
val1: false,
val2: 0,
}
},
methods: {
switchOn(){
this.val1=this.val1==false?true:false
},
addUp(){
setInterval(function(){this.val2++},2000);
}
},
computed:{
change(){ this.addUp(); return this.val2; }
}
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')