我需要将数据传递到场景并将输入中的内容显示到下一个屏幕
i need to pass a data to the scene and display what i put in the input to the next screen
我正在尝试获取我在聊天屏幕输入中填写的数据,但我正在获取该屏幕的关键场景名称。我该如何解决?
标题
<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>
chat
这是名字的问题。 Name 是保存路由器的名称。这就是您必须更改参数名称的原因。
你可以用这个来翻资料。如果你想在 chat
中传递数据
Actions.chat({passname: this.state.name})
您可以在 chat
屏幕中恢复您的数据,如下所示:
<TextInput
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
value={this.props.passname}
我正在尝试获取我在聊天屏幕输入中填写的数据,但我正在获取该屏幕的关键场景名称。我该如何解决?
标题
<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>
chat
这是名字的问题。 Name 是保存路由器的名称。这就是您必须更改参数名称的原因。
你可以用这个来翻资料。如果你想在 chat
Actions.chat({passname: this.state.name})
您可以在 chat
屏幕中恢复您的数据,如下所示:
<TextInput
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
value={this.props.passname}