首页 > 微信 > 详细

小程序 上传图片

时间:2021-05-04 14:15:14      阅读:15      评论:0      收藏:0      [点我收藏+]

获取图片

  • wxml

    <!--pages/publish/publish.wxml-->
    <view bindtap="uploadImage">请上传图片</view>
    <view class="container">
      <image wx:for="{{imageList}}" src="{{item}}"></image>
    </view>
    
    
  • js

      data: {
        imageList: ["/static/hg.jpg", "/static/hg.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)
            });
          }
        });
      },
    

注意:图片目前只是上传到了内存。

小程序 上传图片

原文:https://www.cnblogs.com/angdh/p/14729322.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!