当前位置:网站首页>[uniapp] the uniapp mobile terminal uses uni Troubleshooting of navigateback failure
[uniapp] the uniapp mobile terminal uses uni Troubleshooting of navigateback failure
2022-06-26 17:22:00 【A dying salted fish】
Technology used in the project :
uniapp The navigation bar at the bottom of the mobile terminal uses colorUI Customized in , Not at all uniapp Born in the Central Plains tabbar
Current issues :
A little different tabbar Different... Can be displayed UI page , The key is the page UI All in one URL In the address , That is to say, no matter which one you switch to tabbar, The root path is displayed : /.
Current demand :
It needs to be implemented on a successful order page , Click on < Go back two pages to the mall list page , And the corresponding highlighted... Should be displayed at the bottom tabbar, With uni.navigateBack There is no effect , The specific reason is still unclear .
It was used this.$router.go(-2) There is no problem with the implementation on the browser simulation side , But it still can't be packed on the mobile phone , Here's the picture :
So I started searching aimlessly bug, Try the solution …
It was found later that uniapp Of uni.$emit() Trigger global custom event , You can write the parameters to be carried into the object , And then use uniapp Of uni.$once() Listen for global custom events , Event by uni.$emit Trigger , But only triggered once , Remove the listener after the first trigger 

And then through uni.navigateTo Page Jump , This requirement can be realized
Specific code implementation :
<script>
// Order success page
export default {
name: 'orderSuccess',
methods: {
gotoMall() {
// Go to the mall page , Here we use uni.navigateBack It will fail
// this.$router.go(-2) This method can be simulated on the browser side , But there is a problem on the mobile phone
uni.$emit('changeBar', {
// Bring the required mall Field
paramsName: "mall"
})
uni.navigateTo({
// Jump directly to the home page ( It has been done in the home page tabbar Highlight the mall icon )
url: '/pages/index/index'
})
},
}
}
</script>
<script>
// home page
export default {
onShow() {
// Global monitoring uni.$emit Parameters transmitted
uni.$once('changeBar', function(data) {
// explain : as long as PageCur Is changed to mall, At the bottom of the first page tabbar The mall icon will be highlighted
this.PageCur = data.paramsName
console.log(' Listening for events from changeBar , The carried parameter is :' + data.paramsName);
})
}
}
</script>
边栏推荐
- SQL injection for Web Security (3)
- 并发之线程安全
- Detailed explanation of browser storage methods: the origin and difference of cookies, localstorage and sessionstorage
- NFT 交易市场社区所有化势不可挡
- Use middleware to record slow laravel requests
- Sandboxed container: container or virtual machine
- Microservice architecture practice: business management background and SSO design, SSO client design
- Leetcode - 226. Retourner l'arbre binaire (bfs)
- Army chat -- registration of Registration Center
- Call the random function to generate 20 different integers and put them in the index group of institute a
猜你喜欢

The latest masterpiece of Alibaba, which took 182 days to produce 1015 pages of distributed full stack manual, is so delicious

牛客网:设计LRU缓存结构 设计LFU缓存结构

MySQL index

Which low code platform is more friendly to Xiaobai? Here comes the professional evaluation!

Daily record 2

She said she was tired! So tired! I want to change my career

Jouer avec Linux et installer et configurer MySQL facilement

Alibaba's "high concurrency" tutorial "basic + actual combat + source code + interview + Architecture" is a god class

Synchronized description of concurrency

Inspirational. In one year, from Xiaobai to entering the core Department of Alibaba, his counter attack
随机推荐
The function keeps the value of variable H to two decimal places and rounds the third digit
Discussion: the next generation of stable coins
Detailed explanation of browser storage methods: the origin and difference of cookies, localstorage and sessionstorage
Convert the decimal positive integer m into the number in the forward K (2 < =k < =9) system and output it in bits
Cloud native 02: Alibaba cloud cloud efficient flow pipeline
Calculate the sum of the main diagonals of the array
链游系统开发技术方案设计丨NFT链游系统开发流程及源码
Demonstrate to Xiaobai the case of sub database and sub table
宝藏又小众的CTA动画素材素材网站分享
A simple membership card management system based on Scala
Programmer interview guide - self introduction
SIGIR 2022 | University of Hong Kong and others proposed the application of hypergraph comparative learning in Recommendation System
Here comes the hero League full skin Downloader
Microservice architecture practice: business management background and SSO design: SSO design
Cache breakdown! Don't even know how to write code???
Platform management background and merchant menu resource management: merchant registration management design
Leetcode daily [2022 - 02 - 16]
Web3去中心化存储生态图景
[dynamic planning] Jianzhi offer II 091 Paint the house
【万字总结】以终为始,详细分析高考志愿该怎么填