修复bug: 订单支付之后进入支付成功页 ,点击回退按钮回到了支付页面,项目要求点击回退要进入订单列表页
在支付成功页面加入如下代码:
mounted() {
// 监听页面的回退事件
window.addEventListener('popstate', this.handlePopState);
},
beforeDestroy() {
// 在组件销毁前移除事件监听器,避免内存泄漏
window.removeEventListener('popstate', this.handlePopState);
},
methods: {
handlePopState(event) {
// 这里处理回退事件
console.log('页面回退了', event.state);
// 这里写你的操作
uni.navigateTo({
url:'/pages/mine/order'
})
},
}