Phenomenon description:
Jump from a fast app a to the B1 page of B fast app. A may be a fast app or a card with a negative screen. How can you tell which one comes from?
Solution:
fast application and card jump to other fast applications through router.push interface, which is realized by using the HAP link in deeplink. At the same time, parameters can be carried in the HAP link, and a flag parameter can be added when skipping. Parameters can be obtained from B1 page of B fast application. According to the parameter value, whether the source is a negative screen card or fast application a can be judged, Then do the corresponding logic processing according to the needs. Fast application uses this.xx to get parameters carried by jump.
Example code:
a fast application code:
<template>
<div>
<text class="button" onclick="router">test</text>
</div>
</template>
<style>
.button{
width: 100%;
height: 200px;
color: #000000;
font-size: 80px;
}
</style>
<script>
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=quickapp',
})
}
}
</script>
Card related codes:
<template>
<div>
<text class="button" onclick="router">测试</text>
</div>
</template>
<style>
.button{
width: 100%;
height: 200px;
color: #000000;
font-size: 80px;
}
</style>
<script>
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',
})
}
}
</script>
B fast application code:
In the oninit() life cycle method, the parameter value is obtained. In the following code, the accept variable is defined to receive the parameter value. For example, in the onbackpress() method, different business logic is implemented according to the source.
<template>
<div style="flex-direction: column;">
<text class="text">datas</text>
<text class="text" style="background-color: black">{{accept}}</text>
</div>
</template>
<style>
.text {
height: 80px;
font-size: 50px;
color: red;
width: 500px;
}
</style>
<script>
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;
}
}
</script>
Read More:
- Path cannot be used with params in this. $router. Push() method, otherwise params will be invalid
- Fabric appears when trying to use application call: Unknown: access denied: Channel [mychannel] creator org [org1msp]
- Vue router click the menu bar and the same module reports an error Vue router.esm.js? 2215:2065 Uncaught (in promise) Error
- How to Fix GIT Push Error
- git push error failed to push some refs to solution
- GitHub upload failed: git push error: failed to push some refs to exception handling
- This application has no explicit mapping for /error, so you are seeing this as a fallback (How to Fix)
- How to solve error: failed to push some refs to ‘[email protected]:……git pull conflict
- Three methods of JavaScript jump to new page
- C++ error: jump to case label crosses initialization
- The solution of push D command execution error (/ bin / sh: 1: push D: not found) on Ubuntu
- Browser prompt: Source mapping error: request failed with status 404 Source URL: http://xxx.js Source mapping URL: jquery.min.map
- How to solve the problem of “unable to open source file XXXXX. H” in VS development?
- How to view error information after Android application crash
- Android Studio: Application Installation Failed (How to Fix)
- When MyEclipse starts tomcat, the console doesn’t jump out
- Error in `./a.out‘: free(): invalid next size (fast): 0x0000000001da8010
- Error 1: Vue quickly clicks the route to jump. Error: uncaught (in promise) error: request aborted
- C++ [Error] jump to case label [-fpermissive]
- Servlet page Jump error 500