I want my sHand
to add 6 per second but it works only once, If I try to do something like this: this.sHand++
it works fine and adds 1 degrees per second but I want 6 instead of 1 any solutions?
data:{
sHand: 30
},
computed:{
style(){
return { transform: 'rotate(' + this.sHand + 'deg)'}
}
},
created(){
setInterval(() => {
this.sHand + 6 // not working :/
},1000)
}
<div :style="style" class="secondhand"></div>
You need to assign the value back to
this.sHand
:You have to reassign the value to
this.sHand
after incrementing it.您忘记了作业。
this.sHand++
actually means:this.sHand = this.sHand + 1
因此,它是递增和分配。
会做。