关于项目统一管理android.index.js和ios.index.js

来源:互联网 发布:arp mac 编辑:程序博客网 时间:2024/06/05 17:02

1.统一管理内容写到success.js里面,格式如下:

import React, { Component } from 'react';import { View, Text, Navigator } from 'react-native';export default class Success extends Component {  static get defaultProps() {    return {      title: 'MyScene'    };  }  render() {    return (      <View>        <Text>Hi! My name is {this.props.title}.</Text>      </View>    )  }}

注意点:1.export default必须有;

       2.export default classSuccess extends Component中的Success开头字母必须大写,否则会报错;

3.没有AppRegistry.registerComponent('YoDawgApp',()=> Success)这段代码;



2.android.index.js格式

import React, { Component } from 'react';import {  AppRegistry} from 'react-native';import Success from './success';AppRegistry.registerComponent('AwesomeProject', () => Success);

或者

import React, { Component } from 'react';import { AppRegistry } from 'react-native';import Success from './success';class YoDawgApp extends Component { render() { return ( <Success /> ) }}AppRegistry.registerComponent('AwesomeProject', () => YoDawgApp);

详情参考  http://facebook.github.io/react-native/docs/using-navigators.html




0 0
原创粉丝点击