Jelajahi Sumber

上传组件

彭宇 1 tahun lalu
induk
melakukan
454e0e1bb6
1 mengubah file dengan 10 tambahan dan 2 penghapusan
  1. 10 2
      components/upload/index.vue

+ 10 - 2
components/upload/index.vue

@@ -82,8 +82,8 @@ export default {
         // count: 1, //最多可以选择的图片张数,默认9
         sizeType: ['album', 'camera'],
         success(resp) {
-          let imgCount=resp.tempFiles.length+_this.imgArr.length
-          if ( imgCount> _this.limit) {
+          let fileCount=resp.tempFiles.length+_this.imgArr.length
+          if ( fileCount> _this.limit) {
             uni.showToast({
               title: '上传文件数量不能超过 '+_this.limit+' 个!',
               icon: 'none'
@@ -151,6 +151,14 @@ export default {
         maxDuration: 30,
         success(resp) {
           console.log('视频')
+          let fileCount=1 +_this.imgArr.length
+          if ( fileCount> _this.limit) {
+            uni.showToast({
+              title: '上传文件数量不能超过 '+_this.limit+' 个!',
+              icon: 'none'
+            })
+            return;
+          }
           if (resp.size / 1024 / 1024 > _this.fileSize) {
             uni.showToast({
               title: '上传视频大小不能超过 '+_this.fileSize+' MB!',