ant-design-vue——select下拉框tags清空已選數據

個人需求: select下拉聯動,選擇模板配置後,字段配置從新獲取,此時要清空以前已選的字段app

 

代碼:ui

<template>
    <div>
         <a-form class="dataForm" :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 19 }" @submit="handleCancel">
<a-form-item label="模板配置" v-model="osType">
                    <a-row :gutter="16">
                        <a-col class="gutter-row" :span="22">
                            <a-select placeholder="請選擇" style="width: 100%" v-decorator="['osType',rules.osType]" @change="changeOsType"
                            >
                                <a-select-option v-for="(item,index ) in modeListArr" :key="index" :value="item.key"> {{ item.value }} </a-select-option>
                            </a-select>
                        </a-col>
                        <a-col class="gutter-row" :span="2">
                            <a-icon type="question-circle" />
                        </a-col>
                    </a-row>
                </a-form-item>
     <a-form-item label="字段配置" v-model="fieldList">
                    <a-select mode="tags" placeholder="請選擇" style="width: 100%" v-decorator="['fieldList', rules.fieldList]"
                    >
                        <a-select-option v-for="(item,index ) in fieldListArr" :key="index" :value="item.key"> {{ item.value }} </a-select-option>
                    </a-select>
                </a-form-item>
            </a-form>
  </div>
</template>

<script> export default { data() { return { osType:'', modeListArr:[], fieldList: '', fieldListArr: [],// 配置列表,
               form: this.$form.createForm(this), rules: { osType: { rules: [ { required: true, message: "請選擇", }], initialValue: [], }, fieldList: { rules: [ { required: true, message: "請選擇", }], initialValue: [], }, } } }, mounted(){ let that = this;
        // ···請求接口並處理 ···     that.rules[
'fieldList'].initialValue = ['111']; //初始化示例
        // ···
}, methods: { changeOsType(e) { let that = this; that.osType = e; that.form.setFieldsValue({ //《=關鍵 清空tag選項 'fieldList': [] }) that.fieldList = []; that.fieldListArr = []; },
       handleCancel(){
          ···
       }

  } } </script>
相關文章
相關標籤/搜索