Defines the page launch behavior.
You can add the launchMode attribute to router.page in the manifest file to declare the page launch mode.
Page Launch Mode Attribute
Attribute | Type | Default Value | Mandatory/Optional | Description |
|---|---|---|---|---|
launchMode(1050+) | string | standard | Optional | Page launch mode. The options are singleTask and standard.
|
Sample code
"router": {
"entry": "PageA",
"pages": {
"PageA": {
"launchMode": "singleTask",
"component": "index"
},
"PageB": {
"launchMode": "standard",
"component": "index"
},
"PageC": {
"launchMode": "singleTask",
"component": "index"
}
}
} To open PageA, PageB, PageC, PageB, PageC, and PageA in sequence, perform the following operations:
Two methods are available for dynamic declaration. One is to carry the launch flag attribute in router.push and the other is to carry the launch flag attribute in the link of the page to be opened. The launch flag attribute can control the page opening behavior.
Page Launch Flag Attribute
Attribute | Type | Mandatory/Optional | Description |
|---|---|---|---|
___PARAM_LAUNCH_FLAG___ | string | Optional | Page attribute passed for switching to a quick app page. If this attribute is set to clearTask, all other pages are closed when the target page is opened. If multiple instances of the target page exist, only the earliest instance is reserved and the onRefresh lifecycle function is called back. If no instance of the target page exists, all other pages are closed and an instance is created for the target page. |
Sample code
// Set the page launch flag attribute to clearTask in the 1050+ version.
router.push({
uri: '/PageB',
params: {
___PARAM_LAUNCH_FLAG___: 'clearTask'
}
}) If the page stack consists of PageA, PageB, and PageC in sequence and the page launch flag attribute is set to clearTask for PageB, the logic for opening PageB is as follows:
If the page stack consists of PageA and PageC in sequence and the page launch flag attribute is set to clearTask for PageB, the logic for opening PageB is as follows: