【问题标题】:React native - How to read dynamic form elementsReact native - 如何读取动态表单元素
【发布时间】:2019-03-31 06:36:36
【问题描述】:

我在 React 页面中有动态表单元素,我不确定将所有输入值读取到状态或任何其他可能的解决方案的最佳方法是什么。请提出建议。

render() { 
 {
      answer.map((item) => {
        const code = item.code;
        const question = item.question;
        return (
          <View>
            <FormLabel labelStyle= {{
              color : '#000',
              fontSize: 20
            }}>{question}</FormLabel>

            <FormInput name={code} />

          </View> 
        );
      })
    }  
 }

【问题讨论】:

    标签: reactjs react-native


    【解决方案1】:

    以下代码有效,

    <FormInput name={code} onChangeText={(value) => this.setState({[code]: value})} />
    

    谢谢, 拉贾K

    【讨论】:

      猜你喜欢
      • 2017-11-18
      • 1970-01-01
      • 2021-08-23
      • 1970-01-01
      • 2014-11-28
      • 2019-11-01
      • 2023-03-14
      • 1970-01-01
      • 2018-12-16
      相关资源
      最近更新 更多