我是新来的本地人。
我使用的是NavigatorIOS,但由于限制太多,因此我尝试使用Navigator。在NavigatorIOS中,我可以通过调用来更改视图,this.props.navigator.push()
但是它在Navigator中不起作用,它的结构似乎有所不同。如何在使用导航器时更改视图?
那是最小的导航器-它可以做更多的事情(请参阅最后):
“导航器”视图:
render: function() {
<Navigator style={styles.navigator}
renderScene={(route, nav) =>
{return this.renderScene(route, nav)}}
/>
},
renderScene: function(route,nav) {
switch (route.id) {
case "SomeComponent":
return <SomeComponent navigator={nav} />
case "SomeOtherComponent:
return <SomeOtherComponent navigator={nav} />
}
}
SomeComponent:
onSomethingClicked: function() {
// this will push the new component on top of me (you can go back)
this.props.navigator.push({id: "SomeOtherComponent"});
}
onSomethingOtherClicked: function() {
// this will replace myself with the other component (no going back)
this.props.navigator.replace({id: "SomeOtherComponent"});
}
更多详细信息在这里https://facebook.github.io/react-native/docs/navigator.html,您可以在Samples项目中找到很多示例,这是react-native的一部分:https : //github.com/facebook / react-native / tree / master / Examples / UIExplorer
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句