React Native Elements - 在输入周围包裹可触摸的不透明度在 IOS 中不起作用

Mub*_*ain 5 react-native react-native-elements

我在使用 React Native Elements 文本输入以及使用可触摸不透明度时遇到了一个非常特殊的问题。

import React, { useState } from 'react';
import { TouchableOpacity, View, Dimensions } from 'react-native';
import { Input } from 'react-native-elements';

const test = () => (
  <TouchableOpacity onPress={() => console.log('we hit here')}>
    <Input disabled>
      {children}
    </Input>
  </TouchableOpacity>
)

export default test;
Run Code Online (Sandbox Code Playgroud)

因此输入字段的外缘是完全可点击的,但是组件的中心却无法点击。

不过,这对于 Android 来说非常有效。

有任何想法吗

Mub*_*ain 19

如果有人遇到这个问题,那么您需要提供一个指向“none”的pointerEvents,以便整个组件可点击:

<View pointerEvents='none'>
<Input disabled>
      {children}
    </Input>
</View>
Run Code Online (Sandbox Code Playgroud)


Cha*_*ena 9

Mubeen hussain 的答案是正确的,但更准确地说是这样的

<TouchableOpacity onPress={() => console.log('we hit here')}>
  <View pointerEvents="none">
    <Input disabled>{children}</Input>
  </View>
</TouchableOpacity>
Run Code Online (Sandbox Code Playgroud)