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逻辑
}
Logo

前往低代码交流专区

更多推荐