0
点赞
收藏
分享

微信扫一扫

【无标题】微信小程序上传图片

49路末班车 2022-03-21 阅读 134

// 添加图片 

  pickimg_tap: function () {

    var self = this;

    if (self.data.imgList.length >= 8) {

      AlertMessage(self, '只能选择8张图片!')

      return;

    }

    wx.chooseImage({

      count: 8, // 最多可以选择的图片张数,默认9

      sizeType: ['compressed'], // original 原图,compressed 压缩图,默认二者都有

      sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有

      success: function (res) {

        var tempFilePaths = res.tempFilePaths;

        var lst = self.data.imgList;

        tempFilePaths.forEach(p => {

          if (lst.length >= 8) {

            return;

          }

          lst.push(p);

 

        });

        self.setData({ imgList: lst });

        console.log(self.data.imgList)

      },

      fail: function () {

        // fail

      },

      complete: function () {

        // complete

      }

    })

  },

 

举报

相关推荐

0 条评论