vue3.0取消事件冒泡
element plus取消事件冒泡造成的影响,代码示例为el-dropdown标签。<div @click="doSomething"><span @click="stopPropagation($event)"><el-dropdowntrigger="click"><template #dropdown><el-dropdown-menu
·
element plus取消事件冒泡造成的影响,代码示例为el-dropdown标签。
<div @click="doSomething">
<span @click="stopPropagation($event)">
<el-dropdown trigger="click">
<div>点击</div>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item>item1</el-dropdown-item>
<el-dropdown-item>item2</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown >
</span>
</div>
js部分
const stopPropagation=(e:Event)=>{
e.stopPropagation()
}
const doSomething = ()=>{
// 这里写你的js逻辑
}
更多推荐
已为社区贡献1条内容
所有评论(0)