Skip to content

Max Size limit meesage in mega byte support added #261

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions upload-3.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ export default {
type: Number,
'default': 10240
},
maxSizeErrorInMegaByte: {
type: Boolean,
'default': false
},
// 语言类型
langType: {
type: String,
Expand Down Expand Up @@ -488,7 +492,8 @@ export default {
let that = this,
{
lang,
maxSize
maxSize,
maxSizeErrorInMegaByte
} = that;
// 仅限图片
if (file.type.indexOf('image') === -1) {
Expand All @@ -500,7 +505,13 @@ export default {
// 超出大小
if (file.size / 1024 > maxSize) {
that.hasError = true;
that.errorMsg = lang.error.outOfSize + maxSize + 'kb';
if(maxSizeErrorInMegaByte) {
that.errorMsg = lang.error.outOfSize + Math.round((maxSize/1000)*10)/10 + 'mb';
}
else {
that.errorMsg = lang.error.outOfSize + maxSize + 'kb';
}

return false;
}
return true;
Expand Down