解决方式Vue方式:
您可以使用$once,它只会监听一次事件.
Listen for a custom event, but only once. The listener will be removed once it triggers for the first time.
你只需要将@once添加到@change,如下所示:
export default {
//No Change here
}
检查演示是否在fiddle中.
旧答案:
如果您不想为旋转设置初始值,则可以再增加一个变量:hasRotated以跟踪旋转是否已更改.最初将hasRotated设置为true,一旦旋转已更改,将hasRotated设置为false,如下所示:
export default {
data: {
rotate: 123,
hasRotated: false
},
methods: {
handleRotate () {
if(this.hasRotated){
this.rotate = this.rotate + this.getRotateAngle(e.clientX, e.clientY)
this.hasRotated = false
}
}
}
}