1.在 Screens
資料夾下建立一支 HomeMain.js
2.用 <View>
標籤包裹起來 用了flex
特性 預設佔滿螢幕的高度
=>這邊是可以抽成獨立style檔
import React from 'react';
import {View} from 'react-native';
/** - 首頁 */
const HomeMain = ({navigation}) => {
return (
<View style={{flex: 1}}>
</View>
);
};
export default HomeMain;
這個元件可以接收來自父層接收到的 navigation props
來執行不同的導航操作。以下是一些常見的用法:
navigation.navigate('目標頁面名稱');
navigation.goBack();
navigation.setOptions({ title: '早餐訂單' });
<Stack.Navigator>
<Stack.Screen
name="Home"
component={Order}
options={{headerShown: false}}
/>
<Stack.Screen
options={{
title: '早餐抽抽樂',
}}
name="game"
component={game}
/>
</Stack.Navigator>