小编Ash*_*pta的帖子

在 React Native 中每次按键时键盘都会消失

我想在 react native 中映射键值对。该值是可编辑的文本条目。映射的组件显示正常,但是当我尝试编辑 TextInput 时,当我输入第一个字母时键盘消失了。不知道是什么原因造成的问题。

如果我只是在父元素中放置一个 TextInput,它工作得很好,但在我使用 map 函数时不起作用。

 <View style={styles.main}>
        <View>
            {this._getDetailElements()}
        </View>
 </View>
Run Code Online (Sandbox Code Playgroud)

_getDetailElements() 函数

 _getDetailElements = () => {

    return Object.keys(this.state.data).map(elem => (
        <View key={shortid.generate()} style={styles.element}>
                <TextInput
                editable={this.state.editable}
                onChangeText={text => this.setState({seletedText: text})}
                value={this.state.selectedText}
                /> 
        </View>
    )
    );
}
Run Code Online (Sandbox Code Playgroud)

javascript react-native

6
推荐指数
1
解决办法
3095
查看次数

标签 统计

javascript ×1

react-native ×1