wx.chooseImage(Object object) 从本地相册选择图片或使用相机拍照。
.wxml
<view bindtap="upLoadImage">
请上传图片
</view>
<view>
<image wx:for="{{imageList}}" src="{{item}}" wx:key="11" mode=""/>
</view>
.js
data: {
imageList:["/static/微信图片.jpg","/static/微信图片.jpg"]
},
upLoadImage:function () {
var that=this;
wx.chooseImage({
count:9,
sizeType:['original', 'compressed'],
sourceType:['album', 'camera'],
success:function (res) {
console.log(res);
// that.setData({imageList:res.tempFilePaths})
// 默认图片+选择的图片
that.setData({imageList:that.data.imageList.concat(res.tempFilePaths)})
}
})
},
注意事项:图片目前只是上传到了内存。