uniapp点击返回上一页代码
时间: 2023-08-23 11:04:16 浏览: 100
uniapp点击返回上一页的代码可以使用uni.navigateBack方法来实现。在点击返回按钮时,可以调用uni.navigateBack({ delta: 1 })来返回上一页。其中delta参数表示返回的层数,1表示返回上一级页面。可以参考以下示例代码:
```javascript
onBackPress() {
uni.navigateBack({ delta: 1 });
}
```
这段代码可以放在uniapp的页面实例中的methods中,当点击返回按钮时,调用onBackPress方法即可返回上一页。注意,如果需要在返回上一页时携带参数,可以在上一页的页面实例中修改相应的data值,然后通过uni.navigateBack返回上一页。
#### 引用[.reference_title]
- *1* [uniapp 点击原生按钮返回上一页 点击自定义按钮返回上一页 携带参数](https://blog.csdn.net/qq_52099965/article/details/127980919)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [uniapp中(返回上一页面或多级页面/上拉刷新)](https://blog.csdn.net/m0_58293192/article/details/129166085)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [uniapp点击返回上一页按钮弹出提示框是否确认保存信息](https://blog.csdn.net/growb/article/details/130133761)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文