diff --git a/docs/docs/en.md b/docs/docs/en.md
index 6aa5f34..4aedfdb 100644
--- a/docs/docs/en.md
+++ b/docs/docs/en.md
@@ -549,7 +549,7 @@ Allow upload file extensions
Allow the maximum byte to upload
-* **Type:** `Number`
+* **Type:** `Number | Function`
* **Default:** `0`
@@ -558,10 +558,36 @@ Allow the maximum byte to upload
* **Details:**
`0` is equal to not limit
+ If a `Function` is given, it will be called with the `File` object passed as an argument, and it should return a `Number`
* **Usage:**
```html
+
+
+
+
+
```
diff --git a/docs/docs/zh-cn.md b/docs/docs/zh-cn.md
index 80bf344..3b2733e 100644
--- a/docs/docs/zh-cn.md
+++ b/docs/docs/zh-cn.md
@@ -467,7 +467,7 @@ input标签的 `name` 属性
允许上传的最大字节
-* **类型:** `Number`
+* **类型:** `Number | Function`
* **默认值:** `0`
@@ -476,10 +476,36 @@ input标签的 `name` 属性
* **详细:**
`0` 等于不限制
+ 如果给出了一个`Function`,它就会以作为参数传递的`File`对象被调用,并且应该返回一个`Number`
* **示例:**
```html
+
+
+
+
+
```
diff --git a/src/FileUpload.vue b/src/FileUpload.vue
index 214da26..f1b4de8 100644
--- a/src/FileUpload.vue
+++ b/src/FileUpload.vue
@@ -124,7 +124,7 @@ export default {
},
size: {
- type: Number,
+ type: [Function, Number],
default: 0,
},
@@ -763,7 +763,9 @@ export default {
}
// 大小
- if (this.size > 0 && file.size >= 0 && file.size > this.size) {
+ let size = (typeof this.size === 'function' ? this.size(file) : this.size)
+
+ if (size > 0 && file.size >= 0 && file.size > size) {
return Promise.reject('size')
}