If there is a page that can be returned, it will return directly. uni.navigateBack will automatically refresh the page after failing to return by default, and cannot continue to return
goback() {
// #ifdef H5
let canBack = true;
const pages = getCurrentPages();
// 有可返回的页面则直接返回,uni.navigateBack默认返回失败之后会自动刷新页面 ,无法继续返回
if (pages.length > 1) {
uni.navigateBack(1);
return;
}
// vue router 可以返回uni.navigateBack失败的页面 但是会重新加载
let a = this.$router.go(-1);
// router.go失败之后则重定向到首页
if (a == undefined) {
uni.reLaunch({
url: '/pages/tabbar/index'
});
}
return;
// #endif
uni.navigateBack(1);
}
Click the link to join the group chat [vue front-end Xiaobai communication group]: https://jq.qq.com/?_wv=1027&k=4RfgTyec