This article mainly introduces the relevant information about selecting pictures or taking photos in the WeChat applet chooseImage. Friends who need it can refer to
WeChat applet chooseImage selects pictures or takes photos
1. Use API wx.chooseImage(OBJECT)
var util = require('../../utils/util.js') Page({ data:{ src:"../image/pic4.jpg" }, gotoShow: function(){var _this = this wx.chooseImage({ count: 9, // 最多可以选择的图片张数,默认9 sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有 sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有 success: function(res){ // success console.log(res) _this.setData({ src:res.tempFilePaths }) }, fail: function() { // fail }, complete: function() { // complete } }) }
2. Image path for data binding
<view class="container"> <view> <button type="default" bindtap="gotoShow" >点击上传照片</button> </view> <view> <image class= "show-image" mode="aspectFitf" src="{{src}}"></image> </view> </view>
Exception:
1. wx.chooseImage calls the camera or album
2.
3. Dynamically modify the file path in js
var _this = this wx.chooseImage({ count: 9, // 最多可以选择的图片张数,默认9 sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有 sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有 success: function(res){ // success console.log(res) _this.setData({ src:res.tempFilePaths }) }, fail: function() { // fail }, complete: function() { // complete }
The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
About the code for uploading avatars in WeChat mini programs
About the animation effects of WeChat mini programs Implementation
Introduction to album selection and photo taking in the WeChat applet
The above is the detailed content of About chooseImage in WeChat applet to select pictures or take pictures. For more information, please follow other related articles on the PHP Chinese website!