** In the case that A page has been opened for quick application, if you jump to B page from the card (or other media), click the back button in the upper left corner. The page exit sequence is B-A-card, and you cannot directly return the card (or other media) with one key.
Scenarios to be realized: When the quick app has opened page A, jump from the card (or other media) to the designated page B of the quick app. Click the back button in the upper left corner to exit the quick app with one key and directly return to the card (or other media).
Problem analysis
The above problem occurs because the page adopts the default startup mode standard. In “Standard” mode, A new target page will be opened every time (multiple same pages will exist when the target page address is opened for several times), which results in the cache of page A and page B in sequence in the page stack, and the page will be out of the stack in sequence when exiting, and the page cannot be returned by one key. You are advised to set the startup mode of page B to clearTask dynamically when switching from the card to the quick application. When clearTask is specified, the original page A is cleared and page B is opened. In this way, only page B exists in the page stack and you can exit the quick application when you return.
The solution
Card jump quick application example code (deeplink link) :
<! DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, <meta HTTP-equiv =" x-UA-compatible "content=" IE =edge"> <title> </title> </head> <body> <a href="hwfastapp://com.huawei.hello1/Test? Open ___PARAM_LAUNCH_FLAG___ = clearTask "> using hwfastapp < / a > < br > < br > < a href =" hap: / / app/com. Huawei. Hello1 / Test? Open ___PARAM_LAUNCH_FLAG___ = clearTask "> using the hap < / a > < / body > < / HTML >Copy the code
Quick application target page of card jump (according to the number of current page stack, it can be found that there is always only one page) :
<template> <div class="container"> <text>___PARAM_LAUNCH_FLAG___=</text> <text>{{taskFlag}}</text> <text> <text>{{length}}</text> </div> </template> <style> .container { flex-direction: column; align-content: center; align-items: center; justify-content: center; } text { margin-bottom: 50px; } </style> <script> import router from '@system.router'; export default { data: { // The default is the local app internal image photoUri: '/Common/logo.png', taskflag:'', PARAM_LAUNCH_FLAG:'', length:'' }, onInit() { this.$page.setTitleBar({ text: 'deepLink' }) var that=this; that.taskflag=this.PARAM_LAUNCH_FLAG; Let pages = router.getPages(); To print console.log("tag", this.printjsonArray (router.getPages())); that.length= router.getLength(); console.log("pages' length = "+that.length); }, printJSONArray(array) { let result = "" const suffix = ", " Array.isArray(array) && array.forEach((element, index) => { result = result + JSON.stringify(element) + (index === array.length-1 ? "" : ", ") }) return result } } </script>Copy the code
Suggestions and Conclusions
1. There are two configuration modes for the page startup mode, one is static declaration in the manifest file, and the other is dynamic parameter transmission declaration. Dynamic mode is recommended and can be configured based on your own requirements.
See documentation:
Developer.huawei.com/consumer/cn…
2. The deeplink documents:
Developer.huawei.com/consumer/cn…
The original link: developer.huawei.com/consumer/cn…
Original author: Mayism