(@_@;)我是程序猿,我编程,我快乐,知识改变命运,技术成就梦想   oh yeah!合作VX "w6668263" 联系Email:ye583025823@126.com

Cascader 级联选择器 选择任意一级选项,去掉单选按钮。

Cascader 级联选择器 选择任意一级选项,去掉单选按钮。

 

步骤如下:

1.先设置父子节点取消选中关联,从而达到选择任意一级选项的目的

代码:

<el-cascader :props="{ checkStrictly: true }" clearable></el-cascader>

 

 

2.去掉radio单选框()

    全局添加以下css样式,注意如果只单独添加在vue组件内,样式无效。

代码:

 

.el-radio__inner {
    border-radius: 0;
    border: 0;
    width: 170px;
    height: 34px;
    background-color: transparent;
    cursor: pointer;
    box-sizing: border-box;
    position: absolute;
    top: -18px;
    left: -19px;
}

.el-radio__input.is-checked .el-radio__inner {
    background: transparent;
}

 

 

3.watch监听el-cascader所绑定的值的变化,只要一变化就关闭下拉框。

 

 

 

 

watch: {
        regionCode: {
            handler() {
                if (this.$refs.cascaderRef) {
                    this.$refs.cascaderRef.dropDownVisible = false
                }
            },
            deep: true
        }
    }

 

 

 

vue3

 

 

const groupCascader = ref(null)
const groupPID = ref(['0'])

  watch(
    () => groupPID.value,
    () => {
      groupCascader.value.popperVisible = false
    }
  )

 

posted on 2022-10-31 10:43  一个草率的龙果果  阅读(1145)  评论(0编辑  收藏  举报

导航