aiyide
aiyide
  • 发布:2020-11-16 17:54
  • 更新:2020-11-16 17:58
  • 阅读:641

返回上级页面问题

分类:uni-app

页面A:主页
页面B:分类
页面C:个人中心 (需要登陆)
页面D:登陆页面
ABC,分布都是 tabBar

A->C(需要登陆,跳转D页面),先D页面 我不想登陆,点击返回 ->跳回C页面,C(需要登陆,跳转D页面) 死循环 ,点C页面如何跳回A页面
B->C(需要登陆,跳转D页面),先D页面 我不想登陆,点击返回 ->跳回C页面,C(需要登陆,跳转D页面) 死循环 ,点C页面如何跳回B页面

C页面上级页面不确定, 用户的返回应该如何做?

2020-11-16 17:54 负责人:无 分享
已邀请:
DCloud_uniCloud_JSON

DCloud_uniCloud_JSON

// 在C页面内 navigateBack,将返回A页面
uni.navigateBack({
delta: 2
});
delta: 2 代表返回两级

  • aiyide (作者)

    当 A,C,都是tabBar 的时候 getCurrentPages 不记录 A页面, delta:2 ,是一步一步返回,当执行一次返回(到C页面还是会判断用登陆)结果又跳到D页面,返回不到A页面


    2020-11-16 18:28

  • aiyide (作者)

    getCurrentPages 只记录 switchTab 跳转的页面,很头疼, tabBar 之间的切换没有记录,


    2020-11-16 18:31

  • DCloud_uniCloud_JSON

    回复 aiyide: 提供个思路,给路由套一层方法,然后方法记录路由历史,顺历史记录跳到指定页面。


    2020-11-16 18:35

  • aiyide (作者)

    回复 DCloud_uniCloud_JSON: tabBar 怎么可以获取到记录,我尝试过很多,多获取不到


    2020-11-16 21:38

  • DCloud_uniCloud_JSON

    回复 aiyide: myNavigate(type,OBJECT){

    switch (type){

    case 'navigateTo':

    uni.navigateTo(OBJECT)

    break;

    case 'redirectTo':

    uni.redirectTo(OBJECT)

    break;

    ......//其他方法同上

    default:

    break;

    }

    let historyNavigate = uni.getStorageSync('historyNavigate')

    if(!historyNavigate){historyNavigate=[]}

    historyNavigate.push(OBJECT.url)

    historyNavigate = historyNavigate.slice(-5)//结果保留5步

    uni.setStorageSync('historyNavigate',historyNavigate)

    }


    2020-11-17 10:19

该问题目前已经被锁定, 无法添加新回复