点击多选框,由于v-model多选框会选中或不选中,现在有个需求点击多选框弹出对话框,点击对话框确定才能取消选中
下面展示一些 内联代码片
。
<template>
<!-- `checked` 为 true 或 false -->
<el-checkbox :value="checked" @change="handleChange">备选项</el-checkbox>
</template>
// An highlighted block
<script>
export default {
data() {
return {
checked: true
};
},
methods() {
handleChange(value) {
if(!value) return;
this.$confirm('此操作取消勾选, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.checked = false;
this.$message({
type: 'success',
message: '取消成功!'
});
}).catch(() => {
});
}
}
};
</script>