iT邦幫忙

2024 iThome 鐵人賽

DAY 18
0
佛心分享-SideProject30

用React Native打造找餐店APP系列 第 18

[Day 18] 功能開發-來切第一個頁面吧

  • 分享至 

  • xImage
  •  

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 來執行不同的導航操作。以下是一些常見的用法:

  • push
navigation.navigate('目標頁面名稱');
  • back
navigation.goBack();
  • setTitle
navigation.setOptions({ title: '早餐訂單' });
 <Stack.Navigator>
    <Stack.Screen
      name="Home"
      component={Order}
      options={{headerShown: false}}
    />
    <Stack.Screen
      options={{
        title: '早餐抽抽樂',
      }}
      name="game"
      component={game}
    />
 </Stack.Navigator>

上一篇
[Day 17] 功能開發-製作分頁
下一篇
[Day 19] 功能開發-學習建立組件
系列文
用React Native打造找餐店APP25
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言