我正在尝试获取我在聊天屏幕中输入的数据,但我正在获取该屏幕的关键场景名称。我怎么才能修好它?
标题
<Router>
<Scene key="root" style={{paddingTop:Platform.OS==='ios'? 64:54}}>
<Scene key="Login" component={Login} hideNavBar={true} hideTabBar={true} />
<Scene key="tabbar" tabs={true} tabBarStyle={{backgroundColor:'#fff'}} hideNavBar={true}
>
<Scene key="Home" component={CardList} title="Home" iconName="ios-home" icon={TabIcon}/>
<Scene key="contacts" component={Contacts} iconName="ios-contacts" icon={TabIcon} />
<Scene key='chat' component={Chat} hideTabBar={true} title='Chat'iconName="ios-chatbubbles" icon={TabIcon} />
<
</Scene>
</Scene>
</Router> <View style={style.container}>
<Text> hello{this.props.name}</Text>
</View>合同
state={ name:'',};
render() { return (
<View style={style.container}>
<Text> Enter your name </Text>
<TextInput style={style.textInput} onChangeText={(text)=>{ this.setState({ name: text, }); }} value={this.state.name} />
<TouchableOpacity onPress={()=>{ Actions.chat({ name: this.state.name, }) }} >
<Text> Next </Text>
</TouchableOpacity>发布于 2019-08-08 14:22:26
这是个名字的问题。名称保存了路由器的名称。这就是为什么必须更改参数名的原因。
您可以使用这个来交出数据。如果您希望在chat中传递数据
Actions.chat({passname: this.state.name})可以在chat屏幕中恢复数据,如下所示:
<TextInput
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
value={this.props.passname}https://stackoverflow.com/questions/57413791
复制相似问题