如何在Expo Router中配置符合RESTful规范的动态路由?
Expo Router 配置RESTful路由的问题
我在配置Expo Router时,想要实现标准RESTful路由规范,遇到了路径匹配的问题,核心需求是:
- 让
/organizations/[id]直接渲染详情页(对应show.tsx),而非/organizations/[id]/show - 同时保留
/organizations/[id]/edit路径来渲染编辑页(edit.tsx) - 这两个页面必须处于
/organizations目录下_layout.tsx定义的导航栈中
我当前尝试过两种文件结构:
第一种结构:
app/ (drawer)/ _layout.tsx organizations/ _layout.tsx [id]/ show.tsx edit.tsx
但这种结构会生成/organizations/1/show路径,不符合我的需求。
第二种结构:
app/ (drawer)/ _layout.tsx organizations/ _layout.tsx [id].tsx edit.tsx
这种结构无法实现/organizations/1/edit的路径匹配,达不到预期效果。
我了解Expo Router的动态路由功能,但不想通过[...rest].tsx结合控制流来渲染不同组件的方式实现。想问下有没有遗漏的配置方式?或者是否必须使用动态路由的控制流方案?
内容的提问来源于stack exchange,提问作者Kevin Maze
相关产品推荐
相关产品推荐

