Navigation Navigator.push{object}属性?
我正在绞尽脑汁研究我必须在我的应用程序中将哪些属性传递到Navigation Navigator.push{object}属性?,navigation,react-native,Navigation,React Native,我正在绞尽脑汁研究我必须在我的应用程序中将哪些属性传递到Navigator.push({properties???})。我在React本地网站上找不到任何在线内容 谁能帮帮我吗。。如果你能指出我在哪里可以阅读这些属性,那就太好了 已更新 我的实际问题是使用Navigator从一个页面移动到下一个页面。将推到下一个页面: return ( <React.Navigator initialRoute={{name: 'First Page
Navigator.push({properties???})
。我在React本地网站上找不到任何在线内容
谁能帮帮我吗。。如果你能指出我在哪里可以阅读这些属性,那就太好了
已更新
我的实际问题是使用Navigator从一个页面移动到下一个页面。将推到下一个页面:
return (
<React.Navigator
initialRoute={{name: 'First Page', index: 0, component: MyFirstPage}}
navigationBar={this.getNavigationBar()}
navigator={this.props.navigator}
renderScene={(route, navigator) => {
return (
<View style={{marginTop: 100}}>
<MyFirstPage
title={'MyFirstPage'}
navigator={navigator}
route={route}
/>
</View>
);
}}
/>
);
现在我可以从第1页转到第2页等等。您必须通过路线,例如:
navigator.push({
name: 'Scene ' + nextIndex,
index: nextIndex,
});
如果在renderScene方法中使用route.component进行渲染,则绝对必须存在的唯一组件是组件
:
this.props.navigator.push({
component: About
})
您也只能传入id,并在renderScene方法中检查如下内容:
if (routeId === 'Login') {
return (<Login {...route.passProps} navigator={navigator}/>);
}
var About = React.createClass({
render() {
return (
<View>
<Text>HEllo from About</Text>
<Text>These are the props: { this.props.someprops }</Text>
<Text>MY NAME IS { this.props.name }</Text>
<Text>MY LOCATION IS { this.props.location }</Text>
</View>
)
}
})
还可以通过附着对象来传递要直接在管线本身中使用的特性。大多数情况下,您都会看到这个名为passProps
,但实际上它可以被称为任何您想要的名称:
示例:
this.props.navigator.push({
color: 'white',
component: About,
id: 1
name: {
name: 'Chris'
},
path: {
location: 'Nashville'
},
passProps: {
someprops: someprops
}
})
在renderScene
方法中设置:
renderScene(route, navigator) {
return React.createElement(route.component, { ...this.props, ...route.name, ...route.path, ...route.passProps, navigator, route } )
},
然后像这样使用它:
if (routeId === 'Login') {
return (<Login {...route.passProps} navigator={navigator}/>);
}
var About = React.createClass({
render() {
return (
<View>
<Text>HEllo from About</Text>
<Text>These are the props: { this.props.someprops }</Text>
<Text>MY NAME IS { this.props.name }</Text>
<Text>MY LOCATION IS { this.props.location }</Text>
</View>
)
}
})
var About=React.createClass({
render(){
返回(
你好,从大约
这些是道具:{this.props.someprops}
我的名字是{this.props.NAME}
我的位置是{this.props.LOCATION}
)
}
})
我已经列出了这些例子中的大部分
就是这样,伙计renderScene(route,navigator){return React.createElement(route.component…
在我的代码中,我的代码中总是包含静态组件,这就是为什么我的路由器会转到同一页的原因。谢谢!非常感谢!