博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
React Native项目结构
阅读量:3714 次
发布时间:2019-05-21

本文共 1645 字,大约阅读时间需要 5 分钟。

一、概念

在react-native项目中包含了android和ios的完整的项目结构,可以通过android studio和xcode进行打开和运行,所以可以通过webstorm直接打开react-native的整个项目,然后通过android studio进行打开android项目,用android studio编译运行,在webstorm进行开发。

二、react native项目结构

  1. android文件夹有完整的android项目,可以使用android studio打开,ios文件夹有完整的ios项目,可以用xcode打开。
  2. index.android.js和index.ios.js是入口文件

三、代码流程

(1)、JS入口(以index.android.js为例)

import React, { Component } from 'react';    import {      AppRegistry,      StyleSheet,      Text,      View    } from 'react-native';    export default class hello_world extends Component {      render() {        return (          
Welcome to React Native!
To get started, edit index.android.js
Double tap R on your keyboard to reload,{'\n'} Shake or press menu button for dev menu
); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF', }, welcome: { fontSize: 20, textAlign: 'center', margin: 10, }, instructions: { textAlign: 'center', color: '#333333', marginBottom: 5, }, }); AppRegistry.registerComponent('hello_world', () => hello_world);
  1. class hello_world extends Component:创建APP,并且在render函数中返回UI界面结构。这是定义了一个hello_world的类,里面只有一个渲染函数。
  2. const styles = StyleSheet.create:创建CSS样式
  3. AppRegistry.registerComponent(‘hello_world’, () => hello_world);这个才是JS 程序的入口。即把当前APP的对象注册到AppRegistry组件中, AppRegistry组件是js module。

转载地址:http://voajn.baihongyu.com/

你可能感兴趣的文章
Java类名.方法和变量
查看>>
Java小案例(二) 用数组实现增删查改排序
查看>>
Java小案例(一) 用数组实现登录注册、增加职工并查看信息
查看>>
有趣的一行代码
查看>>
Java函数式编程和面向对象编程
查看>>
Java中List、Map、Set三个接口,存取元素时,各有什么特点?
查看>>
客户端与服务器(C/S架构与B/S架构)、AJax学习
查看>>
jsp中String path = request.getContextPath()的作用
查看>>
登录界面验证码的实现
查看>>
EL表达式
查看>>
Javaweb MVC设计模式、Modle发展史、项目分层和三层架构
查看>>
HTML表格和HTML表单
查看>>
JSP访问数据库,Session对象和九大内置对象
查看>>
Springboot分层图解
查看>>
并查集(Disjiont Set)
查看>>
Java操作HBase
查看>>
Linux编程考前测试题
查看>>
Openstack面试题和知识点总结
查看>>
C++ 实例化一个对象
查看>>
基于Spring boot+Vue的在线考试系统
查看>>