May 18, 2021 WeChat Mini Program Development Document
Select a picture from your local album or take a picture with your camera.
Property | Type | The default | Required | Description |
---|---|---|---|---|
count | number | 9 | Whether | The maximum number of pictures you can select |
sizeType | Array.<string> | ['original', 'compressed'] | Whether | The size of the selected picture |
sourceType | Array.<string> | ['album', 'camera'] | Whether | Select the source of the picture |
success | function | Whether | The interface calls a successful callback function | |
fail | function | Whether | The interface calls the failed callback function | |
complete | function | Whether | Callback function at end of interface call (call succeeds, fails are executed) |
The legal value of object.sizeType
Value | Description | The lowest version |
---|---|---|
original | Original | |
compressed | The compression chart |
The legal value of object.sourceType
Value | Description | The lowest version |
---|---|---|
album | Select a map from the album | |
camera | Use the camera |
Property | Type | Description | The lowest version |
---|---|---|---|
tempFilePaths | Array.<string> | List of local temporary file paths for pictures (local paths) | |
tempFiles | Array.<Object> | A list of local temporary files for the picture | 1.2.0 |
The structure of res.tempFiles
Property | Type | Description |
---|---|---|
path | string | Local Temporary File Path (Local Path) |
size | number | Local temporary file size, unit B |
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success (res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
}
})