欧美综合影院在线影院,国产精品女人久久久久久,日韩精品无码去免费专区,樱花草在线社区WWW日本影院

Menu
小程序資訊
小程序資訊
微信小程序之預(yù)覽圖片
時(shí)間:2016-10-13 18:36:00

 

 

選擇圖片時(shí)可設(shè)置圖片是否是原圖,圖片來(lái)源。這用的也挺常見(jiàn)的,比如個(gè)人中心中設(shè)置頭像,可以與wx.upLoadFile()API使用

主要方法:

wx.chooseImage(object)

wxml

<button type="primary" bindtap="listenerButtonChooseImage">點(diǎn)擊我選擇相冊(cè)button><image src="{{source}}" mode="aspecFill" style="width: 640rpx; height: 640rpx"/>

js

Page({  data:{    // text:"這是一個(gè)頁(yè)面"    source: ''  },  /**   * 選擇相冊(cè)或者相機(jī) 配合上傳圖片接口用   */  listenerButtonChooseImage: function() {      var that = this;      wx.chooseImage({          count: 1,          //original原圖,compressed壓縮圖          sizeType: ['original'],          //album來(lái)源相冊(cè) camera相機(jī)           sourceType: ['album', 'camera'],          //成功時(shí)會(huì)回調(diào)          success: function(res) {              //重繪視圖              that.setData({                  source: res.tempFilePaths              })          }      })  },


wx.previewImage(object)

這又是一個(gè)奇葩API真實(shí)搞不懂怎么用這個(gè)。先模仿下官方咋使用但是沒(méi)有效果,搞懂了在補(bǔ)充下自己的使用

wxml

<button type="primary" bindtap="listenerButtonPreviewImage">展示圖片button>

js

var app = getApp()

  Page({

    data: {

      banner:['../images/big.png', '../images/big.png', '../images/big.png'],

      modalHidden: true

    },

    tapMove:function(e){

      this.setData({ 

        num: e.detail.current+1

      })

    },

/**

  * 預(yù)覽圖片 

  */

   listenerButtonPreviewImage: function() {

       wx.previewImage({

           current: '../images/big.png',


            //這根本就不走

            success: function(res) {

              console.log(res);

            },

            //也根本不走

            fail: function() {

              console.log('fail')

            },

      complete:function(){

        console.log('complete')

      }

         })


       },

onLoad: function () { 

var that = this;

that.setData({

num:1,

count:that.data.banner.length

})


}

})


咨詢
微信掃碼咨詢
電話咨詢
400-888-9358