vue+elementui dropdown 下拉菜单绑定方法

方法一:给el-dropdown根组件监听command ,再el-dropdown-item 绑定commandshuxing值。 methods内详细写监听对应的方法

handleCommand(command) {
if(command == 'loginOut'){
this.$confirm('are you sure loginOut?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: 'loginOut成功!'
});
}).catch(() => {
this.$message({
type: 'info',
message: '已取消loginOut'
});
});
}
// else if(command == 'resetPwd'){
// this.$alert(
// `<input
// placeholder="输入名字搜索"/>`,
// 'notice',
// {
// dangerouslyUseHTMLString: true,
// showClose:true,
// callback: action => {
// this.$message({
// type: 'info',
// message: `action: ${ action }`
// })
// },
// }
// )
// }
},
缺点:如果在处理事件内需要弹出表单元素,则只能使用原生html,无法使用dialog。
方法二:给el-dropdown-item 绑定点击事件。但是无效果,需要用 @click.native=" name"  这样绑定才会有效。 
resetPassword:function(){
this.dialogFormVisible = true
console.log("重置密码")
}
 
posted @ 2019-02-18 11:19  Tutao1995  阅读(11274)  评论(0编辑  收藏  举报