Q群 567530369,小伙伴们都在这里等你哦~

TouchableWithoutFeedback

除非你有一个很好的理由,否则不要用这个组件。所有能够响应触屏操作的元素在触屏后都应该有一个视觉上的反馈(然而本组件没有任何视觉反馈),这也是为什么一个"web"应用总是显得不够"原生"的主要原因之一。

注意TouchableWithoutFeedback只支持一个子节点(不能没有子节点也不能多于一个)。如果你希望包含多个子组件,可以用一个View来包装它们。

译注:常见的使用场景比如想实现点击空白处触发某个操作,那么就可以把空白部分用TouchableWithoutFeedback包起来,或者绝对定位覆盖住。

查看Props

查看类型定义


文档

Props

accessibilityComponentType

> Note: accessibilityComponentTypewill soon be deprecated. When possible, use accessibilityRole and accessibilityStates instead.

类型必填
AccessibilityComponentTypes

accessibilityHint

An accessibility hint helps users understand what will happen when they perform an action on the accessibility element when that result is not obvious from the accessibility label.

类型必填
string

accessibilityLabel

Overrides the text that's read by the screen reader when the user interacts with the element. By default, the label is constructed by traversing all the children and accumulating all the Text nodes separated by space.

类型必填
node

accessibilityRole

类型必填
AccessibilityRoles

accessibilityStates

类型必填
array of AccessibilityStates

accessibilityTraits

类型必填
AccessibilityTraits, ,array of AccessibilityTraits

accessible

类型必填
bool

delayLongPress

从onPressIn开始,到onLongPress被调用的延迟。单位是毫秒.

类型必填
number

delayPressIn

从触摸操作开始到onPressIn被调用的延迟。单位是毫秒。

类型必填
number

delayPressOut

从触摸操作结束开始到onPressOut被调用的延迟。单位是毫秒。

类型必填
number

disabled

如果设为true,则禁止此组件的一切交互。

类型必填
bool

hitSlop

这一属性定义了按钮的外延范围。这一范围也会使pressRetentionOffset变得更大。 注意: 触摸范围不会超过父视图的边界,也不会影响原先和本组件层叠的视图(保留原先的触摸优先级)。

类型必填
object: {top: number, left: number, bottom: number, right: number}

onBlur

Invoked when the item loses focus.

TypeRequired
functionNo

onFocus

Invoked when the item receives focus.

TypeRequired
functionNo

onLayout

当加载或者布局改变的时候被调用,参数为:

{nativeEvent: {layout: {x, y, width, height}}}

类型必填
function

onLongPress

类型必填
function

onPress

当触摸操作结束时调用,但如果被取消了则不调用(譬如响应者被一个滚动操作取代)。

类型必填
function

onPressIn

Called as soon as the touchable element is pressed and invoked even before onPress. This can be useful when making network requests.

类型必填
function

onPressOut

Called as soon as the touch is released even before onPress.

类型必填
function

pressRetentionOffset

在当前视图不能滚动的前提下指定这个属性,可以决定当手指移开多远距离之后,会不再激活按钮。但如果手指再次移回范围内,按钮会被再次激活。只要视图不能滚动,你可以来回多次这样的操作。确保你传入一个常量来减少内存分配。

类型必填
object: {top: number, left: number, bottom: number, right: number}

testID

Used to locate this view in end-to-end tests.

TypeRequired
stringNo

类型定义

Event

类型
Object