cheers-mp-router icon indicating copy to clipboard operation
cheers-mp-router copied to clipboard

路由跳转方式经过beforeEach钩子后,跳转方式丢失

Open wiexin opened this issue 3 years ago • 1 comments

例:在pageA reLaunch 到 pageB,经beforeEach钩子逻辑处理后,实际返回next(pageC),实现pageA到pageC的跳转。实测发现,页面跳转方式变成了 pageA navigateTo 到了pageC

  hook(toRoute, currentRoute, async (v) => {
      if (v === false)
          return;
      else if (typeof v === 'object') {
          try {
              await this.switchRoute(v);
          }
          catch (error) {
              reject(error);
          }
      }
      else {
          next();
      }
  });

原因:当钩子返回一个路由对象时,直接走了this.switchRoute 没有继承原始location的跳转方式

wiexin avatar Feb 08 '22 00:02 wiexin

@wiexin 你的beforeEach怎么写的, 大概提供下测试用例

bigmeow avatar Jun 15 '22 07:06 bigmeow