级联多选器,限制最多选择五个,多出的清除选中
在watch中监听数组变化
<el-cascader ref="cascader" v-model="form.taskType" :options="taskTypeOptions" clearable
:props="{checkStrictly:true,value:'taskCode',multiple: true}" class="small" collapse-tags>
watch: {
'form.taskType'() {
if (this.form.taskType.length > 5) {
this.$message({
type: 'warning',
message: '最多可选择五个',
showClose: true,
})
this.form.taskType.splice(-1, 1);
this.refs.panel.clearCheckedNodes();
}
},