方法一:給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("重置密碼")
}