您的位置:首页 > Web前端 > React

ReactNative安装和使用

2016-03-14 18:45 639 查看
可以先参考 http://zhuanlan.zhihu.com/FrontendMagazine/19996445 这篇文章1.本地下载有Xcode工具,到git 上 https://github.com/facebook/react-native 克隆仓库,或者下载一个zip 压缩包文件2.https://nodejs.org/en/ 下载nodejs 安装3.使用Homebrew 官网提供的指引安装Homebrew http://brew.sh/ 4.安装好Homebrew然后在终端执行以下命令
brew install node
5.接下来使用Homebrew 安装 watchman
brew install watchman
6.使用 npm 安装React Native CLI 工具
npm install -g react-native-cli
这步安装出错时,前面加上 sudo 即可
7.使用CLI 工具构建项目
react-native init PropertyFinder
开始编写前先下载 SublimeText ,找到创建的工程目录下的 index.ios.js 文件用Sublime Text打开,清除里面所有内容开始写一个输出 Hello World !'use strict';var React = require('react-native');var styles = React.StyleSheet.create({text:{color: 'black',backgroundColor: 'white',fontSize: 30,margin: 80}});class AwesomeProjectApp extends React.Component{render(){return React.createElement(React.Text,{style:styles.text},"Hello World!");}}React.AppRegistry.registerComponent('AwesomeProject',function(){return AwesomeProjectApp});编写完成记得保存,运行工程就可以看到界面上显示的 Hello World
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: