发布图片,上传图片个数

小程序 文章 2021-01-25 14:01 411 0 全屏看文

AI助手支持GPT4.0

发布图片,上传图片个数Publish pictures, the number of uploaded pictures

发布图片,上传图片个数

各位前辈大家好,我想请问如何在这段代码中设置上传图片的最少个数,比如最少上传一张图片否则不能发布内容并且做出提示

  chooseImage: function () {    var that = this;    wx.chooseImage({      count9 - that.data.cloudImgList.length,      sizeType: ['original''compressed'],      sourceType: ['album''camera'],      success(res) {        console.log(res.tempFilePaths)        // 上传图片        that.data.tempImgList = res.tempFilePaths        that.uploadImages()      },    })  },  uploadImages() {    var that = this;    for (var i = 0; i < this.data.tempImgList.length; i++) {      wx.cloud.uploadFile({        cloudPath`actionImages/${Math.random()}_${Date.now()}.${this.data.tempImgList[i].match(/.(w+)$/)[1]}`,        filePaththis.data.tempImgList[i],        success(res) {          console.log(res.fileID)          that.data.cloudImgList.push(res.fileID)          that.setData({            cloudImgList: that.data.cloudImgList          })        }      })    }  },

Hello, everyone, I would like to ask how to set the minimum number of uploaded pictures in this code, such as uploading at least one picture, otherwise you can't publish the content and make a prompt "chooseimage: function() {var that = this wx.chooseImage ({      count: 9 -  that.data.cloudImgList .length,      sizeType: ['original',  'compressed'],      sourceType: ['album', 'camera'],      success(res) {         console.log ( res.tempFilePaths )/ / upload pictures that.data.tempImgList  =  res.tempFilePaths          that.uploadImages ()      },    })  },  uploadImages() {    var that = this;     for (var i = 0; i <  this.data.tempImgList .length; i++) {       wx.cloud.uploadFile ({        cloudPath: `actionImages/${ Math.random ()}_ ${ Date.now ()}.${ this.data.tempImgList [i].match(/.(w+)$/)[1]}`,        filePath:  this.data.tempImgList [i],         success(res) {           console.log ( res.fileID )           that.data.cloudImgList .push( res.fileID )           that.setData ({            cloudImgList:  that.data.cloudImgList           })        }      })    }  },

回答:

默认²⁰²⁰:

做判断 当图片数组长度 >=1 在上传 反之弹框即可

brave:

this.data.tempImgList.length >= 1 上传完成后,this.data.tempImgList = []

iW:

不要在选择图片的时候,就上传

1、选择图片,存在一个数组里

2、点击提交按钮,验证数组长度

-EOF-

AI助手支持GPT4.0


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
游戏公测一直显示“已提交”正常吗?及公测量在访问来源中归属于哪个来源?
求助,救助啊。怎么开通小程序红包啊,根据文档,在服务商平台的产品里面没有这个产品
通过在线调试工具调试OA 提交审批接口,结果总是返回 301025
公众号部分用户发送消息 返回服务出现故障
只有小程序体验版才能进入的特定页面,能否开发成后台管理平台来使用?
随便看看
微信公众号免300认证教程 5141
小程序已经上线,作为管理员无法在小程序数据助手查看数据? 4447
小程序广告组件通过审核,但是小程序内没有显示广告? 4418
企业微信通讯录账号被管理员误/恶意删除,怎么办? 8465
问题? 7887
如何快速搭建抽奖助手小程序(无需代码知识) 5249
许涛 大哥在吗, 要解冻小程序的时候提示信息主体不一致, 能帮忙看下吗? 6519
小程序搜一搜全称搜索不显示 麻烦解决一下!谢谢 5816
我的小程序广告收款主体是个体工商户,每个月邮寄两次发票很是麻烦,我年底的时候打包邮寄一次可以么? 5478
如何解决渲染层网络错误Failed to load media? 16731