ant design vue实现后台数据下拉框渲染

1、经常遇到下拉框的数据是后台返回的,此时可以使用v-for遍历即可

<a-form-item name="newChangeType" label="变动类型" labelAlign="right">
   <a-select
    v-model:value="formState.newChangeType"
    placeholder="请选择变动类型"
    autocomplete="off"
    @change="changeType"
   >
       <a-select-option v-for="(item, index) in treeData" :key="index" :value="item.key">
          {
   
   { item.value }}
       </a-select-option>
    </a-select>
</a-form-item>

const treeData = ref<any>([]);

onMounted(() => {
   changeCategory().then((res) => {
      treeData.value = res;
    });
});

猜你喜欢

转载自blog.csdn.net/m0_62626838/article/details/143175396