我有一个任务要在textinput中动态插入选择器值:
像三个选择器值:
['First_Name'],['Last_Name'],['Company_Name']
在textInput中,我想选择选择器值,例如
textInput: [Good Morning ['First_Name'] ['Last_Name'] . ]
代码:
export default class SubjectLine extends Component {
constructor(props){
super(props)
this.state={
msg:'Good Morning',
VariableValue:''
};
}
render() {
return (
<View style={styles.container}>
<Picker
selectedValue={this.state.VariableValue}
style={{height: 50, width: 300,alignSelf:'center',alignItems:'center', padding:25, backgroundColor:'#00bcd4'}}
onValueChange={(itemValue, itemIndex) =>
this.setState({VariableValue: itemValue})
}>
<Picker.Item label="Choose" value="" />
<Picker.Item label="First Name" value="[First_Name]" />
<Picker.Item label="Last Name" value="[Last_Name]" />
<Picker.Item label="Company Name" value="[Company_Names]" />
</Picker>
<TextInput
placeholder="Enter Email Subject Here"
defaultValue={this.state.msg}
onChangeText={(text) => this.setState({VariableValue:text})}
/>
</View>
)
}
}