zoukankan      html  css  js  c++  java
  • 小程序-上传图片

    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)
            });
          }
        })
      }

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

  • 相关阅读:
    hdu2089 不要62
    hdu4734 F(x)
    hdu3555 Bomb
    hdu3652 B-number
    hdu4352 XHXJ's LIS
    CodeForces 55D Beautiful numbers
    数位dp模板
    欧拉函数模板
    UVALive
    常用正则表达 (转)
  • 原文地址:https://www.cnblogs.com/nanjo4373977/p/12868807.html
Copyright © 2011-2022 走看看