element-plus/docs/examples/dropdown/command-event.vue
2021-12-04 11:20:06 +08:00

37 lines
1.0 KiB
Vue

<template>
<el-dropdown @command="handleCommand">
<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 command="a">Action 1</el-dropdown-item>
<el-dropdown-item command="b">Action 2</el-dropdown-item>
<el-dropdown-item command="c">Action 3</el-dropdown-item>
<el-dropdown-item command="d" disabled>Action 4</el-dropdown-item>
<el-dropdown-item command="e" divided>Action 5</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { ElMessage } from 'element-plus'
import { ArrowDown } from '@element-plus/icons-vue'
export default defineComponent({
components: {
ArrowDown,
},
setup() {
const handleCommand = (command) => {
ElMessage(`click on item ${command}`)
}
return {
handleCommand,
}
},
})
</script>