免费观看又色又爽又黄的小说免费_美女福利视频国产片_亚洲欧美精品_美国一级大黄大色毛片

微信小程序wx.getImageInfo()獲取圖片信息的方法

這篇文章主要介紹了微信小程序wx.getImageInfo()獲取圖片信息的方法,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。

創新互聯建站是專業的新巴爾虎右網站建設公司,新巴爾虎右接單;提供網站設計、做網站,網頁設計,網站設計,建網站,PHP網站建設等專業做網站服務;采用PHP框架,可快速的進行新巴爾虎右網站開發網頁制作和功能擴展;專業做搜索引擎喜愛的網站,專業的做網站團隊,希望更多企業前來合作!

一.知識點

微信小程序wx.getImageInfo()獲取圖片信息的方法

二.列子

(1).加載時

<view class="zn-uploadimg">  
  <image src="{{tempFilePaths}}" mode="aspecFill"  />  
  <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, 
        }) 
      } 
    })  
  }  
})

微信小程序wx.getImageInfo()獲取圖片信息的方法

(2).上傳圖片時

<view class="zn-uploadimg"> 
  <button type="primary"bindtap="chooseimage">獲取圖片</button>  
  <image src="{{tempFilePaths}}" mode="aspecFill" />  
  <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, // 默認9  
      sizeType: ['original', 'compressed'], // 可以指定是原圖還是壓縮圖,默認二者都有  
      sourceType: ['album', 'camera'], // 可以指定來源是相冊還是相機,默認二者都有  
      success: function (res) {  
        // 返回選定照片的本地文件路徑列表,tempFilePath可以作為img標簽的src屬性顯示圖片  
        _this.setData({  
          tempFilePaths:res.tempFilePaths  
        })  
        wx.getImageInfo({ 
          src: res.tempFilePaths[0], 
          success: function (res) { 
            _this.setData({ 
              imgwidth:res.width, 
              imgheight:res.height, 
            }) 
          } 
        })  
      }  
    })  
  }  
})

微信小程序wx.getImageInfo()獲取圖片信息的方法

感謝你能夠認真閱讀完這篇文章,希望小編分享的“微信小程序wx.getImageInfo()獲取圖片信息的方法”這篇文章對大家有幫助,同時也希望大家多多支持創新互聯,關注創新互聯行業資訊頻道,更多相關知識等著你來學習!

文章標題:微信小程序wx.getImageInfo()獲取圖片信息的方法
文章網址:http://m.newbst.com/article26/jesscg.html

成都網站建設公司_創新互聯,為您提供關鍵詞優化全網營銷推廣搜索引擎優化網站營銷企業網站制作網站建設

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

網站建設網站維護公司