gpt4 book ai didi

javascript - onRightButtonPress React Native 未定义不是对象 NavigatorIOS

转载 作者:行者123 更新时间:2023-12-03 03:40:14 26 4
gpt4 key购买 nike

这里那里

我的 React Native 代码有问题,我是 React 编程新手,所以无法正确读取错误:-(
希望有人能帮忙

export default class NavigationBar extends Component {

_handleNavigationRequest = () => {
this.refs.nav.push({
component: Settings,
title: 'Genius',
passProps: { myProp: 'genius' },
});
}



render() {
return (
<NavigatorIOS barTintColor='#50C26B' titleTextColor='#fff' tintColor='#fff'
initialRoute={{
component: Genius,
title: 'Happy Genius',
rightButtonTitle: 'Add',
onRightButtonPress: () => this._handleNavigationRequest(),
}}
style={style.navBarStyle}
/>
);
}
}

出现错误:未定义是一个对象(评估“this.refs.nav.push”) enter image description here

最佳答案

您忘记了 NavigatorIOS 中的 ref 参数

render() {
return (
<NavigatorIOS ref='nav'
barTintColor='#50C26B' titleTextColor='#fff' tintColor='#fff'
initialRoute={{
component: Genius,
title: 'Happy Genius',
rightButtonTitle: 'Add',
onRightButtonPress: () => this._handleNavigationRequest(),
}}
style={style.navBarStyle}
/>
);
}

关于javascript - onRightButtonPress React Native 未定义不是对象 NavigatorIOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45659545/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com