【发布时间】:2017-02-13 18:51:41
【问题描述】:
我是导航器的新手,所以也许我缺少一些小东西我希望有人能指出。
我的应用在添加 Navigator 之前可以运行。添加基本实现后,我只看到一个空白屏幕,调试器中没有错误。
这是我在 Navigator 之前的应用:
import React, {
Component, PropTypes
}
from 'react';
import {
Text, View, Navigator, StyleSheet
}
from 'react-native';
import ReasonSelect from './components/ReasonSelect'
import ShippingDetails from './components/ShippingDetails'
import Confirmation from './components/Confirmation'
export
default class CardReplacement extends Component {
render() {
return ( < View > {
eligibilityLoading &&
< View style = {
{
marginTop: 30,
paddingLeft: 15
}
} >
< Text > Loading... < /Text>
</View >
} {
!eligibilityLoading &&
< ReasonSelect / >
} < /View>
);
}
}
这是我添加 Navigator 后的添加(我确实看到此控制台日志有效):
import React, {
Component, PropTypes
}
from 'react';
import {
Text, View, Navigator, StyleSheet
}
from 'react-native';
import ReasonSelect from './components/ReasonSelect'
import ShippingDetails from './components/ShippingDetails'
import Confirmation from './components/Confirmation'
export
default class CardReplacement extends Component {
renderScene(route, navigator) {
if (route.name == "Replacement") {
console.log('working')
return <ReasonSelect navigator = {
navigator
}
/>
}
if(route.name == "Shipping"){
return <ShippingDetails navigator={navigator} / >
}
if (route.name == "Confirmation") {
return <Confirmation navigator = {
navigator
}
/>
}
}
render() {
return (
<View>
{eligibilityLoading &&
<View style={{marginTop: 30, paddingLeft: 15}}>
<Text>Loading...</Text >
< /View>}
{!eligibilityLoading &&
<Navigator
style={{ flex:1 }}
initialRoute={{name: "Replacement"}}
renderScene={this.renderScene}
/ >
} < /View>
);
}
}
我尝试进一步简化,但如果我将导航器更改为:
< Navigator
style = {
{
flex: 1
}
}
initialRoute = {
{
name: "Replacement"
}
}
renderScene = {
(route, navigator) => {
return <ReasonSelect / >
}
}
/>
我错过了什么?
【问题讨论】:
标签: javascript reactjs react-native navigation navigator