vbenjs / vue-vben-admin

A modern vue admin panel built with Vue3, Shadcn UI, Vite, TypeScript, and Monorepo. It's fast!
https://www.vben.pro
MIT License
25.55k stars 6.96k forks source link

ApiTreeSelect 搜索功能失败 #2784

Closed horizon188 closed 1 year ago

horizon188 commented 1 year ago

Describe the bug

搜索失败,在本地搜索是没问题的,但是npm run preview查看的时候就失败了,无法搜索出正确的数据

基本配置: { field: 'categoryIds', label: '视频分类', component: 'ApiTreeSelect', colProps: { span: 8, }, componentProps: { api: getVideoSelectList, // isLeaf: (record) => { // return !(record.levelType < 3); // }, // filterTreeNode: true, treeNodeFilterProp: 'title', showSearch: true, allowClear: true, dropdownStyle: { maxHeight: '400px', overflow: 'auto' }, replaceFields: { children: 'children', key: 'value', value: 'value', }, getPopupContainer: () => document.body, }, },

System Info

horizon188 commented 1 year ago

image

horizon188 commented 1 year ago

在一个vite脚手架上npm run preview后就正常,是vben项目中vite配置问题??

wangjue666 commented 1 year ago
const schemas: FormSchema[] = [
    {
      field: 'field',
      component: 'ApiTreeSelect',
      label: '远程下拉树',
      helpMessage: ['ApiTreeSelect组件', '使用接口提供的数据生成选项'],
      required: true,
      componentProps: {
        api: async () => {
          return [
            {
              title: '选项0',
              value: '0',
              key: '0',
              children: [
                {
                  title: '选项0-0',
                  value: '0-0',
                  key: '0-0',
                },
                {
                  title: '选项0-1',
                  value: '0-1',
                  key: '0-1',
                },
                {
                  title: '选项0-2',
                  value: '0-2',
                  key: '0-2',
                },
              ],
            },
            {
              title: '选项1',
              value: '1',
              key: '1',
              children: [
                {
                  title: '选项1-0',
                  value: '1-0',
                  key: '1-0',
                },
                {
                  title: '选项1-1',
                  value: '1-1',
                  key: '1-1',
                },
                {
                  title: '选项1-2',
                  value: '1-2',
                  key: '1-2',
                },
              ],
            },
          ];
        },
        onChange: (e, v) => {
          console.log('ApiTreeSelect====>:', e, v);
        },
        showSearch: true,
        getPopupContainer: () => document.body,
      },
      colProps: {
        span: 8,
      },
    },
  ];

本地和开发环境测试都没问题呢