如何在React native的textinput中将动态值从选择器插入活动光标?

时间:2019-06-27 16:19:50

标签: reactjs react-native cursor inputbox

我有一个任务要在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>
    )
  }
}

0 个答案:

没有答案