Preview Image
Preview images in full-screen mode in a new page. During the preview, users can save and share the images.
methodName: previewImage
Additional Parameters:
Property | Type | Required | Default | Description |
---|---|---|---|---|
urls | String[] | Yes | List of image URLs to preview. | |
showmenu | Boolean | No | false | Whether to display the save and share menu. |
current | Number | No | The index of the image to display (starting from 1). |
Success Callback Function
Parameters
Object res
Property | Type | Description |
---|---|---|
success | String | Describes whether the interface call was successful or not. "true" for success, "false" for failure. |
Fail Callback Function
Parameters
Object res
Property | Type | Description |
---|---|---|
success | String | Describes whether the interface call was successful or not. "true" for success, "false" for failure. |
errMsg | String | Error message. errMsg enumeration: - Failed to preview image, parameter error: PI001 - Failed to preview image, no permission: PI002 - Failed to preview image, unknown error: PI003 - Failed to preview image, URL is not a valid URL: PI004 |
Example Usage
const dlt = window['@transsion/byteh5bridge'];
const canCallDlt = dlt && window.dltms && window.dltms.isMiniShellGame();
if (canCallDlt) {
dlt.callApi('previewImage', {
urls: JSON.stringify(['xxx.png', 'yyy.png']),
showmenu: true,
current: 1,
success: (res) => {
console.log('Success: ', res);
},
fail: (res) => {
console.log('Fail: ', res);
},
complete: (res) => {
console.log('Complete: ', res);
},
});
}