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

react-native Hello World

2018-02-19 23:09 453 查看
react-native和react用法很相似,如果你用过react,那么学react-native相对容易多了。如果没有学过,也没有关系。
下面是一个react-native的Hello,World!小例子
/**
* Sample React Native App
* https://github.com/facebook/react-native * @flow
*/

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

export default class Xiao extends Component {
render() {
return (
<Text>Hello,world!</Text>
)
}
}

AppRegistry.registerComponent('xiao', () => Xiao);
registerComponent('xiao',()=>Xiao);
react-native中第一个xiao是文件名,不可以改。第二个Xiao和上面的class Xiao extends Component相对应。
react-native还是建立在react基础之上的,不过react-native有自己的用法.<Text>Hello,world!</Text>上面这种写法是一种JSX语法,Text是一个可以显示文本的组件。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  HelloWorld