Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【BasicForm】当组件设置为Upload的时候,multiple属性无效 #240

Closed
quanzaiyu opened this issue Feb 5, 2021 · 4 comments
Closed

Comments

@quanzaiyu
Copy link

quanzaiyu commented Feb 5, 2021

问题描述:当组件设置为Upload的时候,multiple属性无效,设置为false仍然可以添加多个文件。

示例代码:

Snipaste_2021-02-05_14-57-55

结果:

Snipaste_2021-02-05_14-58-34

image

从控制台打印可以看出,添加的是多个文件:

image

预期结果:将multiple设置为false时,只能上传并保存一个文件。

@quanzaiyu
Copy link
Author

尝试使用 maxNumber 属性控制,只是单次选择的时候有效,最终仍然能够选择多个文件

    componentProps: {
      multiple: false,
      emptyHidePreview: true,
      maxSize: 50,
      maxNumber: 1,
      api: async (file: any) => {
        const res = await uploadToOss(file.file, 'cover')
        return { data: res }
      },
    },

效果:

GIF

@anncwb
Copy link
Collaborator

anncwb commented Feb 5, 2021

multiple是选择文件的时候可以多选,如果要限制文件上传数量,应该用maxNumber,这个是bug,我等会修复

anncwb added a commit that referenced this issue Feb 5, 2021
@anncwb anncwb closed this as completed Feb 5, 2021
@Mr-LiuDC
Copy link

Mr-LiuDC commented Apr 20, 2023

我如果多选文件,会多次调用上传接口,请问怎样才能在一次请求中同时上传多个文件?另外怎么拿到返回值啊?

@Darkingtail
Copy link

Darkingtail commented Nov 19, 2023

{ field: 'logoFileId', label: '模组图标', component: 'ImageUpload', componentProps: (props) => { return { api: uploadOrDownloadModule, maxSize: 2, maxCount: 1, resultField: 'result', }; }, rules: [ { required: true, trigger: 'change', type: 'array', message: '请上传模组图标', validator(rule, value) { console.log(value); return !value ? Promise.reject() : Promise.resolve(); }, }, ], },

在BasicForm用ImageUpload;form这个logoFileId字段一直校验没有的,应该怎么给他赋值啊

@github-actions github-actions bot locked and limited conversation to collaborators Aug 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants