上传组件限制

This commit is contained in:
aixianling
2022-04-27 14:41:35 +08:00
parent fbfae4ec41
commit 4b5ada5f9d

View File

@@ -88,8 +88,10 @@ export default {
this.$emit('list', this.fileList) this.$emit('list', this.fileList)
}, },
upload(wait) { upload(wait) {
let count = this.limit - (this.fileList?.length||0)
if(count>0){
let params = { let params = {
count: this.limit, count,
sizeType: ['compressed'], sizeType: ['compressed'],
sourceType: [this.sourceType].flat(), sourceType: [this.sourceType].flat(),
success: (res) => { success: (res) => {
@@ -114,6 +116,10 @@ export default {
} else { } else {
uni.chooseFile(params) uni.chooseFile(params)
} }
}else{
this.$u.toast(`不能超过${this.limit}`)
}
}, },
uploadFile(img) { uploadFile(img) {
if (this.size > 0 && img.size > this.size) { if (this.size > 0 && img.size > this.size) {