0
以下是示例代碼,我正在嘗試react-native-navigationundefined不是一個對象(評估'_this.props.navigator.push')反應本機,當我試圖從一個頁面導航到另一個
我用反應本土的init導航啓動項目 事後我安裝
紗增加反應本地導航@最新
代碼運行完美的第一屏幕,但我想提出來showNextScreen函數的調用它引發錯誤
未定義不是一個對象(評價「this.props.navigator.push」)反應天然
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import {Navigation} from 'react-native-navigation';
import firstPage from './app/components/firstPage';
export default class navigate extends Component {
//function to move to next screen
showNextScreen =() =>{
this.props.navigator.push({
screen: 'firstPage',
title: 'firstScreen'
})
}
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.android.js
</Text>
<Text onPress={this.showNextScreen.bind(this)}
style={styles.instructions}>
Double tap R on your keyboard to reload,{'\n'}
Shake or press menu button for dev menu
</Text>
</View>
);
}
}
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('navigate',() => navigate);
上市等是它必須要在標籤視圖我的申請?,按您的參考鏈接 – devanshsadhotra
@devanshsadhotra有兩種方式來啓動。 TabBased - https://wix.github.io/react-native-navigation/#/top-level-api?id=starttabbasedappparams SingleScreen - https://wix.github.io/react-native-navigation /#/頂級的API?ID = startsinglescreenappparams –