my.setScreenOrientation
Call this API to set screen orientation.
Note: For Android, calling this API to set screen orientation will be effective for all pages on the current mini program by default. When this API is called on a page to set the screen orientation, for example, to
portrait, the screen orientation of all subpages entering from this page will also beportrait, the same as that of this page. Through certain processing, when returning from this page to previous pages, the orientation of these pages will not be affected.
Sample code
my.setScreenOrientation({
orientation: 'portrait',
success: (res) => {
my.alert({
title: 'success',
content: JSON.stringify(res)
})
},
fail: (res) => {
my.alert({
title: 'fail',
content: JSON.stringify(res)
})
}
})Parameters
Property | Type | Required | Description |
orientation | String | Yes | Indicates the orientation of the screen, |
success | Function | No | Callback function upon call success |
fail | Function | No | Callback function upon call failure |
complete | Function | No | Callback function upon call completion (to be executed upon either call success or failure) |
Success callback function
Property | Type | Description |
success | Boolean | Specifies whether the call is successful. When the value is |
Fail callback function
Property | Type | Description |
error | Number | The error code for the failure |
errorMessage | String | The error message that describes the result code in detail |