wxml:
<view class="container">
<image class="image" src="{
{imgPath}}" mode='scaleToFill' bindtap="previewImg"></image>
<button bindtap="selectImg">选择图片</button>
<button bindtap="loadImg">上传图片</button>
</view>
图片选择
wx.chooseImage(object)
从相册中选择图片或是使用拍照
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
count | Number | 否 | 最多可选择图片数量,默认9 |
sizeType | StringArray | 否 | original:原图;compressed:压缩图;默认两者都有 |
sourceType | StringArray | 否 | album:从相册选择;camera:相机拍摄;默认两者都有 |
success | Function | 是 | 成功返回回调函数 |
fail | Function | 否 |