2

TouchableHighlight 似乎没有涵盖我正在使用的整个(卡片)组件。

它似乎仅在我在组件中单击附近或打开时触发。

例如,当我单击没有文本的卡片组件中间时,它不起作用。

https://imgur.com/a/7MkEIrS

我展示了哪些区域不会触发 onPress 的照片。(没有足够的声誉发布图片)

<View>
        <TouchableHighlight
          onPress={() => this.viewDetail(this.props.uid)}
          underlayColor={Colors.clear}
        >
          <Card key={String(this.props.id)} containerStyle={styles.card}>
            <View style={{ flex: 1, flexDirection: "row" }}>
              <View style={{ flex: 1 }}>
                <Text style={styles.title}>{String(this.props.title)}</Text>
              </View>
              <View style={{ flex: 0.5 }}>
                <Text style={styles.price}>€{String(this.props.price)}</Text>
              </View>
            </View>
            <View style={{ flex: 1, flexDirection: "row", marginTop: 15 }}>
              <View style={{ flex: 1 }}>
                <Text style={styles.address}>
                  <Ionicons name="ios-pin" style={styles.icon} />

                  {/* String(
                  " " +
                    this.props.zipcode +
                    " " +
                    this.props.city +
                    ", " +
                    this.props.streetName +
                    " " +
                    this.props.streetNumber
                ) */

                  String(" " + this.props.zipcode + " " + this.props.city)}
                </Text>
              </View>
              <View style={{ flex: 1 }}>
                <Text style={styles.date}>
                  <Ionicons name="ios-time" style={styles.icon} />

                  {String(" " + this.props.date /* .toLocaleDateString() */)}
                </Text>
              </View>
            </View>
          </Card>
        </TouchableHighlight>
      </View>

我希望单击由 TouchableHighlet 包裹的 Comonent 上的任何位置以触发它的 onPress。

实际结果:中间没有触发 onPress 的“盲点”。

4

0 回答 0