脚本
本页内容

脚本

摘要

参考文档 ↗

渲染应用程序的客户端运行时。它应该呈现在文档的 <body> 中。

如果进行服务器端渲染,可以省略 <Scripts/>,应用程序将像传统的没有 JavaScript 的网络应用程序一样工作,完全依赖 HTML 和浏览器行为。

import { Scripts } from "react-router";

export default function Root() {
  return (
    <html>
      <head />
      <body>
        <Scripts />
      </body>
    </html>
  );
}

签名

function Scripts(scriptProps: ScriptsProps): React.JSX.Element | null

属性

scriptProps

要扩展到 <script> 标签上的其他属性,例如 crossOriginnonce 等。

文档和示例 CC 4.0
编辑