Scenes:
app, Android mobile terminal, click the icon in the upper right corner to return to the homepage.
Problem: When using the homeButton from the official website, the icon is displayed normally and can be clicked, but each time it is clicked, it returns to the previous page instead of the home page.
Later I found out that it needs to be used in conjunction with the onNavigationBarButtonTap life cycle function, but nothing happened.
Solution:
Abandon this method and choose the custom buttons provided by the official website pages.json page routing | uni-app official website
Code:
1. Set a custom button on the pages.json page. Here, select the type: home icon provided by the official website and display it on the right.
// 主要代码:
"titleNView": {
"homeButton": "false",
"buttons": [{
"type": "home",
"float": "right"
}]
}
2. Add the onNavigationBarButtonTap function to the corresponding page. I don’t need to distinguish which button is pressed here, so there are no parameters received. If necessary, you can make a judgment according to the official website Page introduction | uni -app official website
Implementation interface:
Reference address:[uniapp] Solve the problem that autoBackButton does not take effect and onNavigationBarButtonTap does not work:_autobackbutton fails_Sun Peng's blog-CSDN blog