【问题标题】:How to create a custom styled 404 page in remix如何在混音中创建自定义样式的 404 页面
【发布时间】:2022-08-09 07:54:23
【问题描述】:

您好,我如何在混音中设计和创建自定义 404 页面。

当识别到路径时,我想用我自己的内容覆盖当前的 404 页面。

标签: remix


【解决方案1】:

您可以编辑root.tsx/root.tsx 中的CatchBoundary 并返回您想要渲染的任何内容。

export function CatchBoundary() {
  const caught = useCatch();

  return (
    <html>
      <head>
        <title>Oops!</title>
        <Meta />
        <Links />
      </head>
      <body>
        <h1>
          {caught.status} {caught.statusText}
        </h1>
        <Scripts />
      </body>
    </html>
  );
}

相关文档:https://remix.run/docs/en/v1/guides/not-found#root-catch-boundary

【讨论】:

    【解决方案2】:

    创建一个routes/$.jsx 文件。

    Link to doc

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-07
      • 1970-01-01
      • 1970-01-01
      • 2011-09-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多