微信小程序如何实现多图上传及预览删除

时间:2024-10-03 14:33:34
  • afterRead(event){
  • console.log(event);
  • var img = event.detail.file;
  • let that = this;
  • let arr = this.data.newArr
  • that.setData({
  • arr:img
  • })
  • console.log(img);
  • img.map(function(v){
  • let imgs = v.url;
  • console.log(imgs);
  • wx.uploadFile({
  • filePath: imgs,
  • name: 'file',
  • url: '你的接口',
  • success(res){
  • let aa = JSON.parse(res.data)
  • let img = aa.front_file
  • console.log(img);
  • arr.push({url:'接口前缀'+img});
  • that.setData({
  • fileList:arr
  • })
  • console.log(that.data.fileList);
  • console.log(that.data.newArr);
  • }
  • })
  • })
  • },