当我将 TouchableHighlight 嵌套在 Modal 中时它不起作用
TouchableHighlight does not work when I nested it in Modal
我在其他屏幕(不是模态)中使用了 touchablehighlight,它们工作正常 properly.But 我不明白为什么当我将它置于模态时它不能正常工作。如果我放置 Button,它就会工作。
这是我的代码的一部分:
请帮助我!
import React,{useState} from 'react'
import {
View,
Text,
Modal,
Button
} from 'react-native';
import { TouchableHighlight } from 'react-native-gesture-handler';
const Icons = () => {
const [modalVisible, setModalVisible] = useState(true);
console.log(modalVisible)
return (
<View >
<TouchableHighlight
onPress={()=>setModalVisible(!modalVisible) }
>
<Text>Son</Text>
</TouchableHighlight>
<Modal
visible={modalVisible}
>
<View >
<View style={{marginBottom: 100, }}>
<Text style={{fontSize:30}} >Hoşgeldiniz</Text>
</View>
<View style={''}>
<TouchableHighlight
onPress={ () => setModalVisible(!modalVisible) }
>
<Text>Sağol</Text>
</TouchableHighlight>
</View>
</View>
</Modal>
</View>
)
}
我也遇到了同样的问题。
从 'react-native' 导入 TouchableHighlight。
但是我不知道为什么我从手势导入时它不起作用。
我在其他屏幕(不是模态)中使用了 touchablehighlight,它们工作正常 properly.But 我不明白为什么当我将它置于模态时它不能正常工作。如果我放置 Button,它就会工作。 这是我的代码的一部分: 请帮助我!
import React,{useState} from 'react'
import {
View,
Text,
Modal,
Button
} from 'react-native';
import { TouchableHighlight } from 'react-native-gesture-handler';
const Icons = () => {
const [modalVisible, setModalVisible] = useState(true);
console.log(modalVisible)
return (
<View >
<TouchableHighlight
onPress={()=>setModalVisible(!modalVisible) }
>
<Text>Son</Text>
</TouchableHighlight>
<Modal
visible={modalVisible}
>
<View >
<View style={{marginBottom: 100, }}>
<Text style={{fontSize:30}} >Hoşgeldiniz</Text>
</View>
<View style={''}>
<TouchableHighlight
onPress={ () => setModalVisible(!modalVisible) }
>
<Text>Sağol</Text>
</TouchableHighlight>
</View>
</View>
</Modal>
</View>
)
}
我也遇到了同样的问题。 从 'react-native' 导入 TouchableHighlight。 但是我不知道为什么我从手势导入时它不起作用。