亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

微信小程序 chooseImage選擇圖片或者拍照

 更新時間:2017年04月07日 10:54:41   投稿:lqh  
這篇文章主要介紹了微信小程序 chooseImage選擇圖片或者拍照的相關(guān)資料,需要的朋友可以參考下

微信小程序 chooseImage選擇圖片或者拍照

一、使用API wx.chooseImage(OBJECT)

var util = require('../../utils/util.js')
Page({
  data:{
    src:"../image/pic4.jpg"
  },
  gotoShow: function(){var _this = this
    wx.chooseImage({
     count: 9, // 最多可以選擇的圖片張數(shù),默認9
     sizeType: ['original', 'compressed'], // original 原圖,compressed 壓縮圖,默認二者都有
     sourceType: ['album', 'camera'], // album 從相冊選圖,camera 使用相機,默認二者都有
     success: function(res){
      // success
      console.log(res)
      _this.setData({
        src:res.tempFilePaths
      })
     },
     fail: function() {
      // fail
     },
     complete: function() {
      // complete
     }
    })
  }
 

二、圖片路徑進行數(shù)據(jù)綁定

<view class="container">
 <view>
  <button type="default" bindtap="gotoShow" >點擊上傳照片</button> 
 </view>
 <view>
  <image class= "show-image" mode="aspectFitf" src="{{src}}"></image>
 </view>
</view>

號外:

  1、wx.chooseImage 調(diào)用相機或相冊
  2、<image class= "show-image" mode="aspectFitf" src="{{src}}"></image> 數(shù)據(jù)綁定
  3、js中動態(tài)修改文件路徑

 var _this = this
    wx.chooseImage({
     count: 9, // 最多可以選擇的圖片張數(shù),默認9
     sizeType: ['original', 'compressed'], // original 原圖,compressed 壓縮圖,默認二者都有
     sourceType: ['album', 'camera'], // album 從相冊選圖,camera 使用相機,默認二者都有
     success: function(res){
      // success
      console.log(res)
      _this.setData({
        src:res.tempFilePaths
      })
     },
     fail: function() {
      // fail
     },
     complete: function() {
      // complete
     }  

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

相關(guān)文章

最新評論