微信小程序把玩(三十二)Image API
主要方法:
wx.chooseImage(object)
wxml
<!--监听按钮-->
<button type="primary" bindtap="listenerButtonChooseImage">点击我选择相册</button>
<!--通过数据绑定的方式动态获取js数据-->
<image src="{
{
source}}" mode="aspecFill" style="width: 640rpx; height: 640rpx"/>
js
wx.previewImage(object)
这又是一个奇葩API真实搞不懂怎么用这个。先模仿下官方咋使用但是没有效果,搞懂了在补充下自己的使用
wxml
<!--图片预览--> <button type="primary" bindtap="listenerButtonPreviewImage">展示图片</button>
js
Page({
data:{
// text:"这是一个页面"
source:
},
/**
* 预览图片 又一个奇葩接口
*/
listenerButtonPreviewImage: function() {
wx.previewImage({
current: http://img.souutu.com/2016/0511/20160511055648316.jpg,
urls: [
http://img.souutu.com/2016/0511/20160511055648316.jpg,
http://img.souutu.com/2016/0511/20160511055650751.jpg,
http://img.souutu.com/2016/0511/20160511054928658.jpg
],
//这根本就不走
success: function(res) {
console.log(res);
},
//也根本不走
fail: function() {
console.log(fail)
}
})
}
})
