React Native 快速搭建商城项目基础结构

一、init指定项目版本(如果直接使用最新版可不要后缀 --verbose --version 0.52.0)

react-native init demo --verbose --version 0.52.0

二、引入必要插件

cd demo/
npm install axios react-native-elements react-native-vector-icons react-navigation react-redux redux redux-thunk query-string prop-types react-native-device-info --save
react-native link react-native-device-info && react-native link react-native-vector-icons

三、启动(RN版本升级会出现一些莫名其妙的坑)
启动失败大概解决方案:
1.在文件根目录执行命令(注意版本)

cd node_modules/react-native/third-party/glog-0.3.4 && ../../scripts/ios-configure-glog.sh

2.Build failed 一步到位命令

rm -rf node_modules/ && npm install && cd ios/ && rm -rf build/ && cd .. && react-native run-ios

3.其他帖子里面也有相关解决办法

四、拷贝并替换代码
1.拷贝下方文件App.js替换掉本项目中该文件
2.拷贝下方文件src文件粘贴到本项目的根目录
3.reload 一下模拟器(这一步之后肯定会报错),在终端执行命令,并在此reload

rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json

文件地址:https://download.csdn.net/download/koufulong/11978558

五、嵌入图标文件

1.在xcode中,将node_modules/react-native-vector-icons下的Fonts文件夹拖入到项目中,并确保选择Create groups


在这里插入图片描述

2.查看Info.plist 中是否有Fonts provided by application,如果没有,手动添加


在这里插入图片描述

或者在info.plist文件中加入以下代码:

<key>UIAppFonts</key>
    <array>
        <string>Entypo.ttf</string>
        <string>EvilIcons.ttf</string>
        <string>Feather.ttf</string>
        <string>FontAwesome.ttf</string>
        <string>Foundation.ttf</string>
        <string>Ionicons.ttf</string>
        <string>MaterialCommunityIcons.ttf</string>
        <string>MaterialIcons.ttf</string>
        <string>Octicons.ttf</string>
        <string>SimpleLineIcons.ttf</string>
        <string>Zocial.ttf</string>
    </array>
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 英语太烂,菜鸟水平,如有不妥之处,请各位大神指正 工作原理 React Native应用程序由JavaScript...
    Juice_gg阅读 9,134评论 0 4
  • Swift1> Swift和OC的区别1.1> Swift没有地址/指针的概念1.2> 泛型1.3> 类型严谨 对...
    cosWriter阅读 13,807评论 1 32
  • ViewPager的作用 ViewPager的功能就是可以使视图滑动,就像Lanucher左右滑动那样。ViewP...
    哇楼主阅读 4,406评论 0 3
  • 很多人说最好的事莫过于我喜欢你的时候你也刚好喜欢我,但是这种几率实在太低了,多数时候是自以为是的一厢情愿,柯柯和六...
    木木家的木木阅读 3,173评论 0 1
  • Repair electronics尊重并保护所有使用服务用户的个人隐私权。为了给您提供更准确、更有个性化的服...
    教书匠来来阅读 2,312评论 0 0