@guren/inertia-客户端
反应的前端 格伦 应用程序,打开 Inertia.js (英语): 客户端靴子、 SSR 条目、 链接和窗体与您的服务器路径相对应.
bun add @guren/inertia-client
脚手架的应用程序已经依赖于它,和 resources/js/app.tsx 是为您生成的.
启动客户端
// resources/js/app.tsx
import { startInertiaClient } from '@guren/inertia-client'
import { pages, pageManifest } from '@/.guren/pages.gen'
startInertiaClient({ pages, pageManifest })
已打入页面
一个页面组件宣布它所需要的道具. Codegen读取了界面 控制器的 this.inertia() 呼叫被选中, 因此重新命名的道具失败 tsc 而不是渲染 undefined数字 :
// resources/js/pages/posts/Index.tsx
import type { PostResourceData } from '@/app/Http/Resources/PostResource'
interface Props {
posts: PostResourceData[]
}
export default function Index({ posts }: Props) {
return <ul>{posts.map((post) => <li key={post.id}>{post.title}</li>)}</ul>
}
输入的链接和窗体
createTypedLink() 财务报告和审定财务报表 createTypedForm() 使用生成的路由清单,并在编译时检查路由名称和参数:
<Link route="posts.show" params={{ id: post.id }}>{post.title}</Link>
子路径导出
| 导入 | 目录 |
|---|---|
@guren/inertia-client | startInertiaClient() 和共享客户端 API |
@guren/inertia-client/server | 安全部门改革入境点 |
@guren/inertia-client/components | createTypedLink(), (中文(简体) ), createTypedForm() |
@guren/inertia-client/typed-forms | RouteBody, (中文(简体) ), RouteErrors和辅助者 |
@guren/inertia-client/channel | 订阅网页的广播 |
@guren/inertia-client/prototype | 首个开发原型的固定后页面 |
文档
这个 前端指南 覆盖页面、版式、表格和SSR.
许可证
麻省理工学院