需要用到react-native-ui-kitten这个组件库,自行点击链接参考去安装
安装完直接用就完事了
js
import { StyleSheet,View, Text} from 'react-native'
import { Modal} from '@ui-kitten/components'
function AlertAction (props) {
const closeModal = () => {
props.closeModal() // 调用父组件的关闭弹窗方法
}
return (
<Modal
animationType="none"
visible={props.visible}
onBackdropPress={closeModal} // 点击外部区域关闭Modal(非中间白色区域)
backdropStyle={{ backgroundColor: 'rgba(0, 0, 0, 0.5)' }}>
<View style={styles.container}>
<Text>111111</Text>
</View>
</Modal>
)
}
export default AlertAction
const styles = StyleSheet.create({
container: {
backgroundColor: '#FFF',
width: 700,
height: 400,
borderRadius: 5,
},
})
使用方法
js
import LanyaModul from '../../components/lanyaModul'
export default function aaa(){
const [lanyamodulflag, setLanYaModulFlag] = useState(true)
// 关闭蓝牙弹窗
const closeModal = () => {
setLanYaModulFlag(false)
}
return (
<LanyaModul
visible={lanyamodulflag}
closeModal={closeModal}
></LanyaModul>
)
}