npx skills add https://github.com/jchaselubitz/drill-app --skill expo-router在 Stack 组件上使用 screenOptions 为所有屏幕设置默认值。不要显式列出每个屏幕——路由会根据文件结构自动发现。
// app/_layout.tsx
import { Stack } from 'expo-router';
export default function RootLayout() {
return (
<Stack screenOptions={{ headerShown: false }} />
);
}
各个屏幕在其组件文件内使用 <Stack.Screen> 配置自己的选项:
// app/lesson/[id].tsx
import { Stack } from 'expo-router';
export default function LessonScreen() {
return (
<View>
<Stack.Screen
options={{
title: 'Lesson',
headerShown: true,
headerBackTitle: 'Back',
}}
/>
{/* 屏幕内容 */}
</View>
);
}
使用 useNavigation 配合 setOptions 来实现动态头部内容,例如按钮:
Use screenOptions on the Stack component to set defaults for all screens. Do NOT explicitly list every screen - routes are auto-discovered from the file structure.
// app/_layout.tsx
import { Stack } from 'expo-router';
export default function RootLayout() {
return (
<Stack screenOptions={{ headerShown: false }} />
);
}
Individual screens configure their own options using <Stack.Screen> within the component file:
// app/lesson/[id].tsx
import { Stack } from 'expo-router';
export default function LessonScreen() {
return (
<View>
<Stack.Screen
options={{
title: 'Lesson',
headerShown: true,
headerBackTitle: 'Back',
}}
/>
{/* Screen content */}
</View>
);
}
Use useNavigation with for dynamic header content like buttons:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
import { useNavigation } from 'expo-router';
import { useLayoutEffect } from 'react';
export default function Screen() {
const navigation = useNavigation();
useLayoutEffect(() => {
navigation.setOptions({
headerRight: () => (
<Pressable onPress={handlePress}>
<Ionicons name="add" size={28} />
</Pressable>
),
});
}, [navigation]);
return <View>{/* 内容 */}</View>;
}
expo-router/unstable-native-tabs)原生标签页提供平台原生的标签栏,在 iOS 上使用 SF Symbols:
// app/(tabs)/_layout.tsx
import { Icon, Label, NativeTabs } from 'expo-router/unstable-native-tabs';
export default function TabLayout() {
return (
<NativeTabs>
<NativeTabs.Trigger name="index" options={{ title: 'Home' }}>
<Icon sf="house.fill" drawable="custom_android_drawable" />
<Label>Home</Label>
</NativeTabs.Trigger>
</NativeTabs>
);
}
app/ 目录结构自动发现。<Stack.Screen> 配置自己的头部/选项。_layout.tsx 文件为其所在目录定义导航结构。(tabs) 这样的括号可以创建路由组,而不会影响 URL 路径。screenOptions 进行路由特定的设置——在路由文件中使用 <Stack.Screen>。每周安装量
80
代码仓库
首次出现
2026年1月25日
安全审计
安装于
gemini-cli73
codex72
opencode72
github-copilot67
cursor60
kimi-cli58
setOptionsimport { useNavigation } from 'expo-router';
import { useLayoutEffect } from 'react';
export default function Screen() {
const navigation = useNavigation();
useLayoutEffect(() => {
navigation.setOptions({
headerRight: () => (
<Pressable onPress={handlePress}>
<Ionicons name="add" size={28} />
</Pressable>
),
});
}, [navigation]);
return <View>{/* content */}</View>;
}
expo-router/unstable-native-tabs)Native tabs provide platform-native tab bar with SF Symbols on iOS:
// app/(tabs)/_layout.tsx
import { Icon, Label, NativeTabs } from 'expo-router/unstable-native-tabs';
export default function TabLayout() {
return (
<NativeTabs>
<NativeTabs.Trigger name="index" options={{ title: 'Home' }}>
<Icon sf="house.fill" drawable="custom_android_drawable" />
<Label>Home</Label>
</NativeTabs.Trigger>
</NativeTabs>
);
}
app/ directory structure<Stack.Screen> within the component_layout.tsx files define navigation structure for their directory(tabs) create route groups without affecting the URL pathscreenOptions for route-specific settings - use <Stack.Screen> in the route fileWeekly Installs
80
Repository
First Seen
Jan 25, 2026
Security Audits
Installed on
gemini-cli73
codex72
opencode72
github-copilot67
cursor60
kimi-cli58
Genkit JS 开发指南:AI 应用构建、错误排查与最佳实践
7,700 周安装
阿里云AI搜索重排测试 - 云搜索优化与AI重排算法验证工具
71 周安装
智能体能力发现工具 - 多智能体系统技能索引与路由决策助手
86 周安装
paper-analyzer:AI学术论文深度解析工具,支持PDF提取、公式讲解与代码分析
85 周安装
cargo-lock-manager:Rust Cargo.lock 文件管理工具,解决构建依赖和CI失败问题
83 周安装
AI协作需求分析工具:ce:brainstorm功能构思与产品决策指南
71 周安装
Flutter开发专家指南:Dart 3.5+、Riverpod状态管理、go_router导航与跨平台组件
87 周安装