1.创建项目

$ react-native init BuyDemo

2.导入图片资源

安卓:把文件夹放到/android/app/src/main/res/目录下,如图:

iOS: Xcode打开工程,把图片拖动到Images.xcassets里

3.根据实际需求,组织项目结构,目的是更加清晰

4.Main.js

/**
* 主页面
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native'; // ES5
var Main = React.createClass({
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Main
</Text>
</View>
);
}
}); const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
}); // 输出
module.exports = Main;

5.index.android.js 引入Main.js并使用这个组件

/**
* android
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native'; /*==============导入外部组件================*/
var Main = require('./Component/Main/Main'); class BuyDemo extends Component {
render() {
return (
<Main />
);
}
} const styles = StyleSheet.create({
}); AppRegistry.registerComponent('BuyDemo', () => BuyDemo);

6.效果图

.

React Native商城项目实战01 - 初始化设置的更多相关文章

  1. React Native商城项目实战10 - 个人中心中间内容设置

    1.新建一个MineMiddleView.js,专门用于构建中间的内容 /** * 个人中心中间内容设置 */ import React, { Component } from 'react'; im ...

  2. React Native商城项目实战07 - 设置“More”界面导航条

    1.More/More.js /** * 更多 */ import React, { Component } from 'react'; import { AppRegistry, StyleShee ...

  3. React Native商城项目实战05 - 设置首页的导航条

    1.Home.js /** * 首页 */ import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Te ...

  4. React Native商城项目实战06 - 设置安卓中的启动页

    1.Main 目录下新建LaunchImage.js: /** * 启动页 */ import React, { Component } from 'react'; import { AppRegis ...

  5. React Native商城项目实战08 - 设置“More”界面cell

    1.自定义可复用的cell More/CommonCell.js: /** * 自定义可复用的cell */ import React, { Component } from 'react'; imp ...

  6. React Native商城项目实战04 - 封装TabNavigator.Item的创建

    1.Main.js /** * 主页面 */ import React, { Component } from 'react'; import { StyleSheet, Text, View, Im ...

  7. React Native商城项目实战03 - 包装Navigator

    1.在Home目录下新建首页详细页HomeDetail.js /** * 首页详情页 */ import React, { Component } from 'react'; import { App ...

  8. React Native商城项目实战02 - 主要框架部分(tabBar)

    1.安装插件,cd到项目根目录下执行: $ npm i react-native-tab-navigator --save 2.主框架文件Main.js /** * 主页面 */ import Rea ...

  9. React Native商城项目实战12 - 首页头部内容

    1.HomeTopView为首页头部内容,HomeTopListView为HomeTopView子视图. 2.HomeTopView.js /** * 首页头部内容 */ import React, ...

随机推荐

  1. CDH配置YARN动态资源分配

    场景:根据不同项目或不同用户,对yarn资源队列进行划分,达到资源管控,任务管控的目的 yarn资源队列参数设置 当设置为 true 时,如果未指定池名称,Fair Scheduler 将会使用用户名 ...

  2. Struts2对于BigDecimal类型的转换问题

    Struts2对常用的数据类型如String.Integer.Double等都添加了转换器进行对应的转换操作. BigDecimal其实也算作是一种常用的数据类型,但Struts2没有对该类型设置转换 ...

  3. git 本地tag和远程tag对应不上 vscode里pull不下代码

    vscode拉取代码是用  git pull --tags origin saas-xxx > git pull --tags origin saas-base From 172.16.0.xx ...

  4. Redis【1】Linux下安装~

    先去Redis官网下载tar.gz文件.点击中间的[Check the downloads page.].再点击中间Stable 模块的[Download]下载 这把我做演示的文件是 redis-5. ...

  5. 聚类算法博客 K-means算法

    最近看到一个 blog 感觉超好.记录下.. http://blog.pluskid.org/?p=17

  6. TCP Retransmission 连接超时

    TCP Retransmission 连接超时 kame 2019/3/17 33 TCP 记一次TCP 连接超时 背景 用户反馈 >> 有出现支付超时.页面问题 (部分情况会出现) 分析 ...

  7. 一文看懂HttpServletResponse

    https://www.jianshu.com/p/8bc6b82403c5 Web服务器收到客户端的http请求,会针对每一次请求,分别创建一个用于代表请求的request对象.和代表响应的resp ...

  8. 枚举类enum应用以及注解@transient应用

    1.增加枚举类 public enum RightTypeEnum { AUTHORITY("访问权限") private String type; RightTypeEnum(S ...

  9. Mysql使用Merge引擎分表--方式及优缺点

    merge:是SQL语句的一种.具体来说,MERGE语句会检查原数据表记录和目标表记录.如果记录在原数据表和目标表中均存在,则目标表中的记录将被原数据表中的记录所更新(执行Update操作):如果目标 ...

  10. java map 根据 map的value值进行排序

    //根据销量排行查询 public void queryGoodsByHotCount(){ //将map集合键和值封装到entry对象中 然后转换成set集合 Set<Entry<Int ...