element-ui Dropdown Events 点击下拉菜单后触发事件的设置


页面结构

<el-dropdown @command="handleCommand"  >
<span class="el-dropdown-link" >

<el-avatar class="user_avatar" :src="this.$store.state.user_avatar"></el-avatar>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="musicLove">喜欢列表</el-dropdown-item>
<el-dropdown-item command="massage">消息中心</el-dropdown-item>
<el-dropdown-item command="history">播放历史</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>

JS结构
methods:{
//通过传入参数形式,回调函数判断下拉菜单item
handleCommand(command){
if (command=="musicLove"){
this.userLove()
}
if (command=="massage"){
this.userMassage()
}
if (command=="history"){
this. userHistory()
}
},
userLove(){
console.log('喜欢列表')
},
userMassage(){
console.log("消息记录")

},
userHistory(){
console.log("历史记录")
},


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM