手机浏览器使用HTML5 input的multiple属性上传多张图片目前支持的只有华为自带浏览器(未测),谷歌浏览器(未测),QQ浏览器(亲测可以)。如只在微信公众号打开可用微信js sdk
wx.chooseImage({
count: 1, // 默认9
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
var localIds = res.localIds; // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
}
});
<input type="file" multiple accept='image/*'></input>
<AtImagePicker
multiple
files={this.state.files}
onChange={this.onChange.bind(this)}
onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)}
/>
taro-ui的AtImagePicker在QQ浏览器同样亲测支持