el-dropdown-menu如何获取下拉选择的项
时间: 2023-03-29 15:00:20 浏览: 209
mxjs-dropdown-menu
el-dropdown-menu 可以通过监听下拉菜单的 select 事件来获取用户选择的项,具体代码如下:
```
<el-dropdown @command="handleCommand">
<span class="el-dropdown-link">
下拉菜单<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="item1">选项一</el-dropdown-item>
<el-dropdown-item command="item2">选项二</el-dropdown-item>
<el-dropdown-item command="item3">选项三</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<script>
export default {
methods: {
handleCommand(command) {
console.log(command); // 获取用户选择的项
}
}
}
</script>
```
阅读全文