React Native商城项目实战01 - 初始化设置
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 - 初始化设置的更多相关文章
- React Native商城项目实战10 - 个人中心中间内容设置
1.新建一个MineMiddleView.js,专门用于构建中间的内容 /** * 个人中心中间内容设置 */ import React, { Component } from 'react'; im ...
- React Native商城项目实战07 - 设置“More”界面导航条
1.More/More.js /** * 更多 */ import React, { Component } from 'react'; import { AppRegistry, StyleShee ...
- React Native商城项目实战05 - 设置首页的导航条
1.Home.js /** * 首页 */ import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Te ...
- React Native商城项目实战06 - 设置安卓中的启动页
1.Main 目录下新建LaunchImage.js: /** * 启动页 */ import React, { Component } from 'react'; import { AppRegis ...
- React Native商城项目实战08 - 设置“More”界面cell
1.自定义可复用的cell More/CommonCell.js: /** * 自定义可复用的cell */ import React, { Component } from 'react'; imp ...
- React Native商城项目实战04 - 封装TabNavigator.Item的创建
1.Main.js /** * 主页面 */ import React, { Component } from 'react'; import { StyleSheet, Text, View, Im ...
- React Native商城项目实战03 - 包装Navigator
1.在Home目录下新建首页详细页HomeDetail.js /** * 首页详情页 */ import React, { Component } from 'react'; import { App ...
- React Native商城项目实战02 - 主要框架部分(tabBar)
1.安装插件,cd到项目根目录下执行: $ npm i react-native-tab-navigator --save 2.主框架文件Main.js /** * 主页面 */ import Rea ...
- React Native商城项目实战12 - 首页头部内容
1.HomeTopView为首页头部内容,HomeTopListView为HomeTopView子视图. 2.HomeTopView.js /** * 首页头部内容 */ import React, ...
随机推荐
- leetcode 980. Unique Paths III
On a 2-dimensional grid, there are 4 types of squares: 1 represents the starting square. There is e ...
- 092、部署Graylog日志系统(2019-05-16 周四)
参考https://www.cnblogs.com/CloudMan6/p/7808708.html Graylog 是与 ELK 可以相提并论的一款几种式日志管理方案,支持数据收集.检索.可视化 ...
- 23、selenium爬取歌曲精彩评论
我们这次试试用selenium爬取QQ音乐的歌曲评论,我选的歌是<甜甜的>. https://y.qq.com/n/yqq/song/000xdZuV2LcQ19.html f ...
- tomcat部署项目时 报错Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web modules
Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web modules 解决方法: 找到文件 .set ...
- knative 安装
knative 安装 本文安装版本 knative 0.6. 准备 安装 knative 前需要事先安装 Kubernetes 集群 和 Istio. 安装 下载安装所需要的文件.以下选择的是全安装, ...
- FMDB-FMDatabaseQueue
FMDB封装了SQLite3的方法,操作数据库变得很简单. 增删改查变简单之后,那么问题来了,如何使用多线程优化对数据库的操作? 这是我们的第一反应估计是dispatch_async(). 那么问题又 ...
- PAT Basic 1076 Wifi密码 (15 分)
下面是微博上流传的一张照片:“各位亲爱的同学们,鉴于大家有时需要使用 wifi,又怕耽误亲们的学习,现将 wifi 密码设置为下列数学题答案:A-1:B-2:C-3:D-4:请同学们自己作答,每两日一 ...
- ListView的创建
里面涉及到很多知识 包括3D样式的去除,重绘ListView控件,以及处理控件的边框颜色 // Test_listview_1.cpp : Defines the entry point for th ...
- Python开发WebService:REST,web.py,eurasia,Django
Python开发WebService:REST,web.py,eurasia,Django 博客分类: Python PythonRESTWebWebServiceDjango 对于今天的WebSe ...
- SP Flash Tool版本对应MTK处理器型号(SP Flash Tool 版本速查)
SP Flash Tool v3.1224.0.100 MT6516,MT6573,MT6573,MT6575,MT6575,MT6577, SP Flash Tool v3.1332.0.187 M ...