簡體   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