Bug Type:Component
Environment
- Vue Version:
3.2.33
- Element Plus Version:
2.1.10
- Browser / OS:
UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36
- Build Tool:
Vite
Reproduction
dropdown-item设置disabled属性绑定的单击事件仍能执行,command则不会
Related Component
el-dropdown-item
Reproduction Link
Element Plus Playground
Steps to reproduce
<template>
<el-dropdown>
<span class="el-dropdown-link">
Dropdown List<el-icon class="el-icon--right"><arrow-down /></el-icon>
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click="handledisabledclick" disabled>disabled</el-dropdown-item>
<el-dropdown-item @click="handleenabledclick" >enabled</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</template>
<script lang="ts" setup>
import { ElMessage } from 'element-plus'
import { ArrowDown } from '@element-plus/icons-vue'
const handledisabledclick=()=>{
ElMessage(`disabled click`)
};
const handleenabledclick=()=>{
ElMessage(`enabled click`)
}
</script>
<style scoped>
.example-showcase .el-dropdown-link {
cursor: pointer;
color: var(--el-color-primary);
display: flex;
align-items: center;
}
</style>
What is Expected?
What is actually happening?
Additional comments
- (empty)*
3条答案
按热度按时间ymdaylpp1#
Since the
click
event is directly bound to the component, unless thenative disabled
property is triggered, it will be disabled, similar toel-button/el-input
, this needs to be discussedshyt4zoc2#
style disabled
.el-dropdown-menu__item.is-disabled:active{ pointer-events: none; }
baubqpgj3#
这是个bug应该被修复,现目前给出以下解决方案:
el-dropwn-menu
组件设置 CSS pointer-events 属性 (推荐)command
进行事件代理el-drop-item
外层嵌套一层div
标签,将点击事件绑定在该div
上