首页 > 解决方案 > 当我在 TextInput 中获得焦点时单击其他元素

问题描述

当我在 TextInput 中打开键盘时。如果我单击其他组件没有响应,并且键盘关闭。

如果键盘打开,如何让其他元素对我的触摸做出反应?

编码:

<View style={{flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center' }} >
        <TouchableOpacity onPress={ () => console.log('aaaa')}>    
          <Image source={require('Assets/images/icons/back.png')} />
        </TouchableOpacity>

        <TextInput
          style={[{height: 35, textAlignVertical: 'center', paddingTop: 0, paddingBottom: 0, color: 'white'}]}
          placeholder="Music expert, company or music style..."
          onChangeText={this.changeText}
          autoFocus={true}
        />

        <TouchableOpacity onPress={ () => console.log('aaaa')}>    
          <Image source={require('Assets/images/icons/close.png')} />
        </TouchableOpacity>
      </View>
</View>

如果我专注于 TexInput 并单击任何 ToucableOpacity 这只是关闭键盘,但不显示 console.log

标签: react-nativemobiletouchtextinput

解决方案


推荐阅读