[英]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.