当前位置:网站首页>[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>
边栏推荐
- 有依赖的背包问题
- 去中心化NFT交易协议将击败OpenSea
- Detailed contract quantification system development scheme and technical description of quantitative contract system development
- 直播预告|程序员进击,如何提升研发效能?6月21日晚视频号、B站同步直播,不见不散!
- sql中ROUND和TRUNCATE的区别(四舍五入还是截取小数点后几位)
- Platform management background and merchant menu resource management: merchant registration management design
- 背包问题求方案数
- sparksql如何通过日期返回具体周几-dayofweek函数
- [recommendation system learning] recommendation system architecture
- Which low code platform is more friendly to Xiaobai? Here comes the professional evaluation!
猜你喜欢

Concurrent thread safety

数字藏品与NFT到底有何区别

【uniapp】uniapp手机端使用uni.navigateBack失效问题解决

VSCode使用 - Remote-SSH 配置说明

Interpretation of new plug-ins | how to enhance authentication capability with forward auth

Distributed Architecture Overview

Leetcode HOT100 (22--- bracket generation)

Platform management background and merchant menu resource management: Design of platform management background data service

【推荐系统学习】推荐系统的技术栈

丰富专业化产品线, 江铃福特领睿·极境版上市
随机推荐
She said she was tired! So tired! I want to change my career
[recommendation system learning] technology stack of recommendation system
A simple membership card management system based on Scala
[code Capriccio - dynamic planning] t583. Deleting two strings
MySql 导出数据库中的全部表索引
用redis做用户访问数据统计HyperLogLog及Bitmap高级数据类型
Necessary decorator mode for 3 years' work
Discussion: the next generation of stable coins
Detailed explanation of browser storage methods: the origin and difference of cookies, localstorage and sessionstorage
Notes on flowus
Implementation of MySQL master-slave architecture
[latex bearer] use tables in \title (error \begin doesn't match its definition.)
Some explanations for latex CJK
Detailed contract quantification system development scheme and technical description of quantitative contract system development
类型多样的石膏PBR多通道贴图素材,速来收藏!
【代码随想录-动态规划】T583、两个字符串的删除操作
What is the difference between digital collections and NFT
The latest masterpiece of Alibaba, which took 182 days to produce 1015 pages of distributed full stack manual, is so delicious
对NFT市场前景的7个看法
Vue--vuerouter cache routing component