繁体   English   中英

Flowrouter-必须重新加载整个页面才能识别路线

[英]Flowrouter - have to reload whole page for route to be recognised

相当基本的设置-用户提交帖子,通过方法将其插入,然后应将用户转到带有新创建帖子的_id的确认页面:

const onSubmitPost = (post) => {
      createPost.call(post, (err, res) => {
        if(err) {
          instance.errorMessage.set(err.reason);
        } else {
          FlowRouter.go("create-post/:postId/confirm", { postId: res });
      }
   });
};

// Route definition    
FlowRouter.route("/create-post/:postId/confirm", {
  name: "create-confirm",
  action() {
    BlazeLayout.render("MainPage", { content: "ConfirmPostContainer" });
  }
});

但是当我尝试这样做时,我得到There is no route for the path: create-post/abc123/confirm

如果我手动按重新加载,则效果很好-没问题。

任何人都知道发生了什么,以及如何解决?

编辑

  • 这是在/create-post路由上调用的-在/create-post重定向以确认该帖子
  • 添加路线定义
  • 尝试使用redirect而不是go -没什么区别

我可以建议您尝试2件事情。 我的直觉是,问题源于使用相对路径从/create-post调用.go方法。

因此,首先尝试使用路由名称: FlowRouter.go('create-confirm', { postId: res });

其次,尝试绝对路径: FlowRouter.go('/create-post/' + res + '/confirm'); -注意前导斜杠/

那样有用吗?

尝试FlowRouter.redirect(您的路线名称,{postId:res}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM