ant design vue 关于select 请求数据后没有立即显示的问题

设置:filterOption 属性为false

vben admin框架中封装了ant design vue select组件在使用提供的updaeSchema函数时只能更新一次,有知道解决的老铁可以告诉我.代码如下:

 {
    field: 'package',
    label: '套餐项目',
    component: 'ApiSelect',
    componentProps: ({ formActionType })=>{
      const fetchData = ref<OptionsItem[]>([]);
      const fetchTest = debounce(values=>{
        console.log('test:', values);
        const httpData = {
          c_id: 1,
          param: values
        };
        getchildrenTest(httpData).then(res => {

          console.log('res:', res);
          const item = res.map(test=> {
            return {
            label: `${test.name}`,
            value: test.id,
          }});
          fetchData.value = item;

        })


      },1000);
      watch(()=>fetchData.value,()=>{
        console.log('fetchData):',fetchData.value);
        formActionType.updateSchema([{
          field:'package',
          componentProps:{
            options:fetchData.value,
            showSearch: true,
            filterOption:false,
            mode: 'multiple',
          },
        }]);
      })

      return{
      // api: getchildrenTest,
      labelField: 'name',
      valueField: 'id',
      showSearch: true, 
      mode: 'multiple',
      onSearch: fetchTest,
      // params:{c_id: 1},
      filterOption: false,

      // filterOption: (input,options)=>{
      //   return options?.label.toLowerCase().indexOf(input.toLowerCase()) >=0;
      // },
      }

    },
    colProps: { span: 24 },
  },


来自为知笔记(Wiz)


posted on 2024-08-11 02:18  白衣风云  阅读(21)  评论(0编辑  收藏  举报

导航