el-cascader 可多选并且父子节点不关联,最多选中5个

求助,有什么办法能够解决;

    changeDepartment(val) {
      if (val.length > 5) {
        this.$message.error("最多选择5个科室");
        // this.oldSelectedDeparttId 在data中声明一个空数组
        // this.selectedDeparttId 组件v-model绑定的
        this.selectedDeparttId = [...this.oldSelectedDeparttId];
      }else{
        this.selectedDeparttId = val
        this.oldSelectedDeparttId = [...this.selectedDeparttId];
      }
    },

解决问题方法

另外再加个变量存选中项,加@change事件   判断选中数量小于6,用选中值赋给v-model绑的变量和新增的变量

否则就把新增的变量赋值给v-model上绑的那个

你的意思是只能选中五个超过就没法选了?

multiple: true,
checkStrictly: true,  props里有这两个属性