vue js 阻止事件冒泡
本来想用preventDefault来阻止冒泡,但是没有效果
于是试了vue.js提供的v-on的事件修饰符,参考博文
其中 @click.stop阻止单击事件继续传播
<template>
<div class="rabbit" ref="rabbit" @click.stop="clickRun($event)">
</div>
</template>
clickRun(e) {
//在click后面加上.stop,可以直接阻止单击事件继续传播
// if (e) {
// e.preventDefault()
// }
if(this.IsRun) {
clearTimeout(this.timecode)
this.IsRun = false
} else {
this.timefun()
this.IsRun = true
}
}