最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序wx.getImageInfo()如何獲取圖片信息

 更新時(shí)間:2018年01月26日 11:44:05   作者:面條請不要欺負(fù)漢堡  
這篇文章主要為大家詳細(xì)介紹了微信小程序wx.getImageInfo()如何獲取圖片信息,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android九宮格圖片展示的具體代碼,供大家參考,具體內(nèi)容如下

一.知識點(diǎn)

二.列子

(1).加載時(shí)

<view class="zn-uploadimg">  
  <image src="{{tempFilePaths}}" mode="aspecFill" style="width: 100%; height: 450rpx" />  
  <text>圖片的大?。簕{imgwidth}}px*{{imgheight}}px</text> 
</view> 
var app = getApp()  
Page({ 
  data: {  
    tempFilePaths: '../uploads/foods.jpg', 
    imgwidth:0, 
    imgheight:0,  
  }, 
  onReady:function(){ 
    // 頁面渲染完成  
    var _this = this;  
    wx.getImageInfo({ 
      src: _this.data.tempFilePaths, 
      success: function (res) { 
        _this.setData({ 
          imgwidth:res.width, 
          imgheight:res.height, 
        }) 
      } 
    })  
  }  
}) 

(2).上傳圖片時(shí)

<view class="zn-uploadimg"> 
  <button type="primary"bindtap="chooseimage">獲取圖片</button>  
  <image src="{{tempFilePaths}}" mode="aspecFill" style="width: 100%; height: 450rpx"/>  
  <text>圖片的大小:{{imgwidth}}px*{{imgheight}}px</text> 
</view> 
.zn-uploadimg{ 
  padding:1rem; 
} 
.zn-uploadimg image{ 
  margin:1rem 0; 
}
var app = getApp()  
Page({ 
  data: {  
    tempFilePaths: '',  
    imgwidth:0, 
    imgheight:0, 
  }, 
  /**  
   * 上傳圖片 
   */ 
  chooseimage: function () {  
    var _this = this;  
    wx.chooseImage({  
      count: 1, // 默認(rèn)9  
      sizeType: ['original', 'compressed'], // 可以指定是原圖還是壓縮圖,默認(rèn)二者都有  
      sourceType: ['album', 'camera'], // 可以指定來源是相冊還是相機(jī),默認(rèn)二者都有  
      success: function (res) {  
        // 返回選定照片的本地文件路徑列表,tempFilePath可以作為img標(biāo)簽的src屬性顯示圖片  
        _this.setData({  
          tempFilePaths:res.tempFilePaths  
        })  
        wx.getImageInfo({ 
          src: res.tempFilePaths[0], 
          success: function (res) { 
            _this.setData({ 
              imgwidth:res.width, 
              imgheight:res.height, 
            }) 
          } 
        })  
      }  
    })  
  }  
}) 

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

天门市| 汉中市| 濮阳县| 应用必备| 衡阳市| 石河子市| 嘉善县| 白朗县| 西城区| 星座| 宝应县| 兴城市| 盖州市| 通州区| 阿克苏市| 临夏市| 大理市| 余江县| 临武县| 桐柏县| 白城市| 海晏县| 大竹县| 株洲县| 冀州市| 思茅市| 南漳县| 曲周县| 罗田县| 辽阳市| 潞西市| 五常市| 永宁县| 麻城市| 乐都县| 平顶山市| 涞水县| 阜阳市| 宁强县| 嘉义市| 郴州市|