A tutorial on how to distinguish the sources and channels of router.push jump fast applications
The main content of this article is to explain "how to distinguish the source channel of router.push jump fast application". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the tutorial on how to distinguish the source channels of router.push jump fast applications.
Phenomenon description:
Jump from a fast application A to the B1 page of B fast application, A may be a fast application or a negative one-screen card, how to tell which one it comes from?
Solution:
Fast applications and cards are transferred to other fast applications through the router.push interface, using the hap link in Deeplink. At the same time, parameters can be carried in the hap link. Add a flag parameter when skipping over, get the parameters in the B1 page of the B fast application, and judge whether the source is a negative one-screen card or fast application An according to the parameter value, and then do the corresponding logic processing according to the need. Fast App uses this.xx to obtain the parameters carried by the jump.
Sample code:
A quick application code:
Test .button {width: 100%; height: 200px; color: # 000000; font-size: 80px;} import router from'@ system.router' Module.exports = {data: {}, onInit () {this.$page.setTitleBar ({text:'})}, router () {console.log ("router") Router.push ({uri: 'hap://app/com.huawei.ceshi/Test?body=card',// card parameter})}}
B Quick Application Code:
Get the parameter values in the onInit () lifecycle method, and the following code defines the accept variable to receive the parameter values, such as implementing different business logic based on the source in the onBackPress () method.
The following is the data received {{accept}} .text {height: 80px; font-size: 50px; color: red; width: 500px;} import router from'@ system.router' Module.exports = {data: {accept: ""}, onInit () {this.$page.setTitleBar ({text:'}) this.accept = this.body;}, onBackPress () {if (this.accept = "quickapp") {console.log ("this is quickapp") } else if (this.accept = "quickapp") {console.log ("this is crad");} else {router.back ()} return true }} at this point, I believe you have a deeper understanding of the "method tutorial to distinguish the source channels of router.push jump fast applications". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!