欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序 圖片上傳實(shí)例詳解

 更新時(shí)間:2017年05月05日 11:30:17   投稿:lqh  
這篇文章主要介紹了微信小程序 圖片上傳實(shí)例詳解的相關(guān)資料,需要的朋友可以參考下

一.了解wx.chooseImage(OBJECT)

二.代碼編程

在pages文件里面創(chuàng)建uploadimg文件夾

1.編寫頁面結(jié)構(gòu):uploadimg.wxml

<view class="container" style="padding:1rem;"> 
  <button type="primary"bindtap="chooseimage">獲取圖片</button>  
  <image src="{{tempFilePaths }}" mode="aspecFill" style="width: 100%; height: 450rpx;margin:1rem 0;"/>  
</view>


2.設(shè)置數(shù)據(jù):uploadimg.js

//獲取應(yīng)用實(shí)例  
var app = getApp()  
Page({ 
  data: {  
    tempFilePaths: '',  
  }, 
  /**  
   * 上傳圖片 
   */ 
  chooseimage: function () {  
    var _this = this;  
    wx.chooseImage({  
      count: 1, // 默認(rèn)9  
      // 可以指定是原圖還是壓縮圖,默認(rèn)二者都有  
      sizeType: ['original', 'compressed'],  
      // 可以指定來源是相冊還是相機(jī),默認(rèn)二者都有 
      sourceType: ['album', 'camera'],  
     // 返回選定照片的本地文件路徑列表,tempFilePath可以作為img標(biāo)簽的src屬性顯示圖片   
      success: function (res) {  
     
        _this.setData({  
         tempFilePaths:res.tempFilePaths  
        })  
      }  
    })  
  }  
}) 

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

最新評論