mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 10:20:19 +08:00
feat(Uploader): max-size、max-count can be string
This commit is contained in:
parent
e2f1e6810b
commit
45038f548e
@ -123,8 +123,8 @@ export default {
|
|||||||
| after-read | Hook after reading the file | *Function* | - |
|
| after-read | Hook after reading the file | *Function* | - |
|
||||||
| before-read | Hook before reading the file, return false to stop reading the file, can return Promise | *Function* | - |
|
| before-read | Hook before reading the file, return false to stop reading the file, can return Promise | *Function* | - |
|
||||||
| before-delete | Hook before delete the file, return false to stop reading the file, can return Promise | *Function* | - |
|
| before-delete | Hook before delete the file, return false to stop reading the file, can return Promise | *Function* | - |
|
||||||
| max-size | Max size of file | *number* | - |
|
| max-size | Max size of file | *number \| string* | - |
|
||||||
| max-count | Max count of image | *number* | - |
|
| max-count | Max count of image | *number \| string* | - |
|
||||||
| result-type `v2.2.7` | Type of file read result, can be set to `file` `text` | *string* | `dataUrl` |
|
| result-type `v2.2.7` | Type of file read result, can be set to `file` `text` | *string* | `dataUrl` |
|
||||||
| upload-text | Upload text | *string* | - |
|
| upload-text | Upload text | *string* | - |
|
||||||
| image-fit `v2.1.5` | Preview image fit mode | *string* | `cover` |
|
| image-fit `v2.1.5` | Preview image fit mode | *string* | `cover` |
|
||||||
|
@ -137,10 +137,10 @@ export default {
|
|||||||
| deletable `v2.2.12` | 是否展示删除按钮 | *boolean* | `true` |
|
| deletable `v2.2.12` | 是否展示删除按钮 | *boolean* | `true` |
|
||||||
| capture | 图片选取模式,可选值为`camera`(直接调起摄像头) | *string* | - |
|
| capture | 图片选取模式,可选值为`camera`(直接调起摄像头) | *string* | - |
|
||||||
| after-read | 文件读取完成后的回调函数 | *Function* | - |
|
| after-read | 文件读取完成后的回调函数 | *Function* | - |
|
||||||
| before-read | 文件读取前的回调函数,返回`false`可终止文件读取,支持返回`Promise` | *Function* | - |
|
| before-read | 文件读取前的回调函数,返回`false`可终止文件读取,<br>支持返回`Promise` | *Function* | - |
|
||||||
| before-delete | 文件删除前的回调函数,返回`false`可终止文件读取,支持返回`Promise` | *Function* | - |
|
| before-delete | 文件删除前的回调函数,返回`false`可终止文件读取,<br>支持返回`Promise` | *Function* | - |
|
||||||
| max-size | 文件大小限制,单位为`byte` | *number* | - |
|
| max-size | 文件大小限制,单位为`byte` | *number \| string* | - |
|
||||||
| max-count | 文件上传数量限制 | *number* | - |
|
| max-count | 文件上传数量限制 | *number \| string* | - |
|
||||||
| result-type `v2.2.7` | 文件读取结果类型,可选值为`file` `text` | *string* | `dataUrl` |
|
| result-type `v2.2.7` | 文件读取结果类型,可选值为`file` `text` | *string* | `dataUrl` |
|
||||||
| upload-text | 上传区域文字提示 | *string* | - |
|
| upload-text | 上传区域文字提示 | *string* | - |
|
||||||
| image-fit `v2.1.5` | 预览图裁剪模式,可选值见 [Image](#/zh-CN/image) 组件 | *string* | `cover` |
|
| image-fit `v2.1.5` | 预览图裁剪模式,可选值见 [Image](#/zh-CN/image) 组件 | *string* | `cover` |
|
||||||
|
@ -36,11 +36,11 @@ export default createComponent({
|
|||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
maxSize: {
|
maxSize: {
|
||||||
type: Number,
|
type: [Number, String],
|
||||||
default: Number.MAX_VALUE,
|
default: Number.MAX_VALUE,
|
||||||
},
|
},
|
||||||
maxCount: {
|
maxCount: {
|
||||||
type: Number,
|
type: [Number, String],
|
||||||
default: Number.MAX_VALUE,
|
default: Number.MAX_VALUE,
|
||||||
},
|
},
|
||||||
deletable: {
|
deletable: {
|
||||||
|
@ -29,7 +29,10 @@ export function readFile(file: File, resultType: ResultType) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isOversize(files: File | File[], maxSize: number): boolean {
|
export function isOversize(
|
||||||
|
files: File | File[],
|
||||||
|
maxSize: number | string
|
||||||
|
): boolean {
|
||||||
return toArray(files).some(file => file.size > maxSize);
|
return toArray(files).some(file => file.size > maxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user