<template>
<transition name="slide">
<div class="top_box" @click="topTop($event)" v-if="show" title="回到頂部">
<i class="iconfont icon-huidaodingbu"></i>
</div>
</transition>
</template>
...
methods: {
toTop (event) {
console.log(event.currentTarget)
console.log(event.target)
}
}
...
在vue中event.target
始終是綁定事件的節點,而event.currentTarget
指向的是被點擊到的節點,如上,如果點擊i標籤,event.target
是div,而event.currentTarget
指向的是i標籤。