加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

React Native布局实践:开发京东客户端首页遇到的坑

发布时间:2020-12-15 08:17:34 所属栏目:百科 来源:网络整理
导读:找到一个React Native实现的京东客户端首页的demo,很兴奋的下载下来了,地址:https://github.com/yuanguozheng/JdApp。 要把他跑起来也是遇到了些坑。 1,源代码中引入Component时全都是用的这种方式 import React,{ AppRegistry, Component, Navigator, St

找到一个React Native实现的京东客户端首页的demo,很兴奋的下载下来了,地址:https://github.com/yuanguozheng/JdApp。

要把他跑起来也是遇到了些坑。

1,源代码中引入Component时全都是用的这种方式

import React,{
AppRegistry,
Component,
Navigator,
StyleSheet,
TouchableOpacity,
Text
} from 'react-native';

这样是不行的,Component是在'react'中的,应该这样

import React,{ Component } from 'react';
import {
AppRegistry,
Text
} from 'react-native';

MenuButton.js中的PropTypes也是在'react'中的,应该这样写

import React,{ PropTypes,Component } from 'react';
import {
View,
Text,
Image,
TouchableWithoutFeedback,
StyleSheet
} from 'react-native';

2.遇到跑起来后遇到这种异常


是因为那东西没导入,这样导入:npm install react-native-tab-navigator --save

同样还有一个react-native-viewpager 导入:npm install react-native-viewpager --save

3.然后又报了这个异常


这个可能是因为用的strict模式,打开debug即可,正常运行了。

最后附上运行效果:

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读