wxml

1 <view bindtap="uploadImage">请上传图片</view>
2 <view class="container">
3    <image wx:for="{{imageList}}" src="{{item}}"</image>
4 </view>

js

data: {
    "imageList":["/static/1.jpg","/static/2.jpg"]
  },
uploadImage:function(){
    var that = this;

    wx.chooseImage({
      count:9, //最大上传图片张数
      sizeType:['original','compressed'], //图片尺寸
      sourceType:['album','camera'], //图片来源
      success:function(res){
        // 设置imageList,页面上的图片自动修改
        // that.setData({
        //   imageList:res.tempFilePaths
        // });

        //默认图片+选择的图片
        that.setData({
          imageList:that.data.imageList.concat(res.tempFilePaths)
        });
      }
    })
  }

 注意事项:图片只是上传到内存

相关文章:

  • 2021-11-19
  • 2021-11-18
  • 2022-12-23
  • 2021-12-26
  • 2021-12-06
  • 2021-07-30
  • 2021-08-11
猜你喜欢
  • 2021-11-29
  • 2022-01-11
  • 2021-10-26
  • 2021-09-17
相关资源
相似解决方案