Hab*_*ibi 21 react-native navigator-ios
我在我的本机应用程序上使用NavigatorIOS.我想在导航回上一个路线时传递一些属性.
一个示例案例:我在表单页面中.提交数据后,我想回到之前的路线并根据提交的数据做一些事情
我该怎么办?
mut*_*utp 22
代码示例显示如何在弹出之前使用回调.这是专门针对Navigator而不是NavigatorIOS,但也可以应用类似的代码.
你有Page1和Page2.您正从Page1推送到Page2,然后弹回Page1.你需要从Page2传递一个回调函数,它会触发Page1中的一些代码,然后才会弹出回到Page1.
在第1页 -
_goToPage2: function() {
this.props.navigator.push({
component: Page2,
sceneConfig: Navigator.SceneConfigs.FloatFromBottom,
title: 'hey',
callback: this.callbackFunction,
})
},
callbackFunction: function(args) {
//do something
console.log(args)
},
Run Code Online (Sandbox Code Playgroud)
在第2页 -
_backToPage1: function() {
this.props.route.callback(args);
this.props.navigator.pop();
},
Run Code Online (Sandbox Code Playgroud)
函数"callbackFunction"将在"pop"之前调用.对于NavigatorIOS,您应该在"passProps"中执行相同的回调.您还可以将args传递给此回调.希望能帮助到你.
| 归档时间: |
|
| 查看次数: |
17316 次 |
| 最近记录: |