Javascript 屏幕导航不适用于参数React Navigation
我在我的应用程序内页中有此编码 我想点击wifi列表项,然后打开wifi屏幕 屏幕3是Tab navigator的屏幕,在使用stack Navigation进行身份验证布局后激活 我的编码如下 screenthree.jsJavascript 屏幕导航不适用于参数React Navigation,javascript,react-native,Javascript,React Native,我在我的应用程序内页中有此编码 我想点击wifi列表项,然后打开wifi屏幕 屏幕3是Tab navigator的屏幕,在使用stack Navigation进行身份验证布局后激活 我的编码如下 screenthree.js import React,{Component}来自“React”; 导入{ 看法 样式表 }从“反应本族语”; 从“本机基”导入{容器、标题、内容、列表、列表项、文本、图标、左侧、正文、右侧、开关}; 类ScreenThree扩展组件{ render(){ 返回( th
import React,{Component}来自“React”;
导入{
看法
样式表
}从“反应本族语”;
从“本机基”导入{容器、标题、内容、列表、列表项、文本、图标、左侧、正文、右侧、开关};
类ScreenThree扩展组件{
render(){
返回(
this.props.navigation.navigate('WifiScreen'{
项目编号:86,
otherParam:“这里有你想要的任何东西”,
})}>
无线局域网
极客
);
}
}
导出默认屏幕3;
const styles=StyleSheet.create({
容器:{
弹性:1,
对齐项目:'中心',
辩护内容:“中心”
}
});代码>您正试图获取类之外的参数WifiScreen
。这就是它出错的原因。您应该从类中获取参数。像下面这样
class WifiScreen extends Component{
render(){
const {itemId, otherParam} = this.props.navigation.state.params;
return (
<View style={styles.container}>
<Text>WifiScreen</Text>
<Text>itemId: {JSON.stringify(itemId)}</Text>
<Text>otherParam: {JSON.stringify(otherParam)}</Text>
</View>
);
}
}
类WifiScreen扩展组件{
render(){
const{itemId,otherParam}=this.props.navigation.state.params;
返回(
WifiScreen
itemId:{JSON.stringify(itemId)}
otherParam:{JSON.stringify(otherParam)}
);
}
}
我想在一些函数中使用参数,这些函数不是在Render方法中调用的,在这里我可以定义const{params}=this.props.navigation.state.params;