React Native 中使用路由

在React Native 中使用路由,android 和 ios 的安装步骤是不一样的,这里使用社区的 react-navigation

react navigation 官方文档

ios安装步骤:

  1. npm install react-navigation --save
  2. npm install react-native-gesture-handler --save
  3. npm install react-navigation-stack @react-native-community/masked-view --save
  4. npm install react-native-reanimated react-native-screens react-native-safe-area-context --save
  5. cd ios
  6. pod install
  7. cd ../
  8. npm run ios

Android步骤:
前四步同 ios

  1. npm install react-navigation --save

  2. npm install react-native-gesture-handler --save

  3. npm install react-navigation-stack @react-native-community/masked-view --save

  4. npm install react-native-reanimated react-native-screens react-native-safe-area-context --save

  5. 请在android/app/build.gradle 中 dependencies 选项中添加下面这两行:

    implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'
    
  6. cd ../

  7. npm run android

好啦,这就是 ios 和 android 的安装步骤啦 ~

发布了23 篇原创文章 · 获赞 33 · 访问量 1267

猜你喜欢

转载自blog.csdn.net/weixin_44691775/article/details/104434813