当前位置:网站首页>[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>
边栏推荐
- Leetcode - 226. Retourner l'arbre binaire (bfs)
- Today, I met a "migrant worker" who took out 38K from Tencent, which let me see the ceiling of the foundation
- Some explanations for latex CJK
- 20:第三章:开发通行证服务:3:在程序中,打通redis服务器;(仅仅是打通redis服务器,不涉及具体的业务开发)
- 【代码随想录-动态规划】T583、两个字符串的删除操作
- Viteconfigure project path alias
- Find out the maximum value of each column element of NxN matrix and store it in the one-dimensional array indicated by formal parameter B in order
- Halcon's region: features of multiple regions (5)
- 20: Chapter 3: develop the pass service: 3: get through the redis server in the program; (it only connects with the redis server and does not involve specific business development)
- Synchronized description of concurrency
猜你喜欢

物联网协议的王者:MQTT

Classical synchronization problem

玩转Linux,轻松安装配置MySQL

halcon之区域:多种区域(Region)特征(5)

对NFT市场前景的7个看法

Microservice architecture practice: user login and account switching design, order query design of the mall

mysql Add column 失败 因为之前有数据,不是默认null 不行

Programmer's essential toolkit, please collect!

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

Today, I met a "migrant worker" who took out 38K from Tencent, which let me see the ceiling of the foundation
随机推荐
Discussion: the next generation of stable coins
COMP5216 Mobile Computing Assignment 1 - Extending ToDoList app
Here comes the hero League full skin Downloader
【万字总结】以终为始,详细分析高考志愿该怎么填
国信证券怎么开户?通过链接办理股票开户安全吗
Multiply the values of the upper triangular elements of the array by M
halcon之区域:多种区域(Region)特征(5)
[recommendation system learning] recommendation system architecture
Wechat app mall, review products, upload commodity pictures, and score Commodity Services
Strength and appearance Coexist -- an exclusive interview with Liu Yu, a member of Apache pulsar PMC
牛客网:设计LRU缓存结构 设计LFU缓存结构
[qt learning notes]qt inter thread data communication and data sharing
MySql 导出数据库中的全部表索引
Troubleshooting ideas that can solve 80% of faults!
[latex bearer] use tables in \title (error \begin doesn't match its definition.)
Viteconfigure project path alias
Rich professional product lines, and Jiangling Ford Lingrui · Jijing version is listed
Getting started with mongodb
Platform management background and merchant menu resource management: Design of platform management background data service
Technical scheme design of chain game system development - NFT chain game system development process and source code