Rendering

renderToStringAsync

编辑此页面
import { renderToStringAsync } from "solid-js/web"
function renderToStringAsync<T>(
fn: () => T,
options?: {
timeoutMs?: number
renderId?: string
nonce?: string
}
): Promise<string>

renderToString 相同,但是在返回结果之前会等待所有 <Suspense> 边界解析完成。 资源数据会自动序列化到 script 标签中,并在客户端加载时进行水合。

renderId 用于在有多个顶级根节点时对渲染进行命名空间隔离。

const html = await renderToStringAsync(App)

选项

名称类型描述
timeoutMsnumber等待 <Suspense> 边界解析的超时时间(毫秒)。
renderIdstring用于渲染的 id。
noncestring用于 script 标签的 nonce 值。
报告此页面问题