vue Ant Design 树选择使用(选中子节点显示各级父节点;选中父节点不选中子节点)

效果图:

 <a-descriptions-item label="治疗方式">
            <a-form-model-item prop="treatments">
              <template>
                <a-tree-select
                  labelInValue
                  v-model="otherFrom.treatments"
                  show-search
                  style=" 100%"
                  :value="otherFrom.treatments"
                  :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
                  :tree-data="treatmentData"
                  placeholder="请选择治疗方式"
                  allow-clear
                  multiple
                  tree-default-expand-all
                  @change="onChange"
                  @search="onSearch"
                  @select="onSelect"
                >
                </a-tree-select>
              </template>
            </a-form-model-item>
          </a-descriptions-item>
方法:

methods: {
    onChange(value, e) {
      console.log(value);
      for (let i = 0; i < value.length; i++) {
        value[i].label = value[i].value;
      }
      this.otherFrom.treatments = value;
    },

}
原文地址:https://www.cnblogs.com/xiaolucky/p/14169036.html