replace

replace

这是一个围绕 redirect 的小封装器,它将使用 history.replaceState 而不是 history.pushState 触发客户端重定向到新位置。

¥This is a small wrapper around redirect that will trigger a client-side redirect to the new location using history.replaceState instead of history.pushState.

如果 JavaScript 尚未加载,这将表现为标准文档级重定向,并将向历史记录堆栈添加一个新条目。

¥If JavaScript has not loaded, this will behave as a standard document-level redirect and will add a new entry to the history stack.

与 目录中的 redirectResponseInit 和 文件一样,(和 )文件将参与基于文件系统的自动路由。

¥Just like redirect, it accepts a status code or a ResponseInit as the second parameter:

replace(path, 301);
replace(path, 303);
replace(path, {
  headers: {
    "Set-Cookie": await commitSession(session),
  },
});
Remix v2.17 中文网 - 粤ICP备13048890号