facebook官网“导航栏demo”怎么运行,附代码



  • http://facebook.github.io/react-native/docs/using-navigators.html
    代码是
    import React, { Component, PropTypes } from 'react'; import { Navigator, Text, TouchableHighlight, View } from 'react-native'; export default class SimpleNavigationApp extends Component { render() { return ( <Navigator initialRoute={{ title: 'My Initial Scene', index: 0 }} renderScene={(route, navigator) => <MyScene title={route.title} // Function to call when a new scene should be displayed
    onForward={ () => { const nextIndex = route.index + 1; navigator.push({ title: 'Scene ' + nextIndex, index: nextIndex, }); }} // Function to call to go back to the previous scene
    onBack={() => { if (route.index > 0) { navigator.pop(); } }} /> } /> ) } } class MyScene extends Component { static propTypes = { title: PropTypes.string.isRequired, onForward: PropTypes.func.isRequired, onBack: PropTypes.func.isRequired, } render() { return ( <View> <Text>Current Scene: { this.props.title }</Text> <TouchableHighlight onPress={this.props.onForward}> <Text>Tap me to load the next scene</Text> </TouchableHighlight> <TouchableHighlight onPress={this.props.onBack}> <Text>Tap me to go back</Text> </TouchableHighlight> </View> ) } }

    我把AppRegistry.registerComponent('FacebookNavDemo', () => SimpleNavigationApp);指向SimpleNavigationApp,import { Navigator, Text, TouchableHighlight, View ,AppRegistry} 里也加了AppRegistry
    但运行app说MyScene 的render方法那有问题。大家能运行吗,怎么回事



  • 0_1469437614011_QQ截图=.png



  • care about



  • 官网的例子啊,怎么运行不出来,字符也调成utf-8了