RN封装的model弹出层组件

需要用到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>
	)
}
相关推荐
树上有只程序猿18 分钟前
终于有人把数据库讲明白了
前端
猩兵哥哥24 分钟前
前端面向对象设计原则运用 - 策略模式
前端·javascript·vue.js
司宸24 分钟前
Prompt设计实战指南:三大模板与进阶技巧
前端
RoyLin26 分钟前
TypeScript设计模式:抽象工厂模式
前端·后端·typescript
华仔啊32 分钟前
Vue3+CSS 实现的 3D 卡片动画,让你的网页瞬间高大上
前端·css
江城开朗的豌豆40 分钟前
解密React虚拟DOM:我的高效渲染秘诀 🚀
前端·javascript·react.js
vivo互联网技术1 小时前
拥抱新一代 Web 3D 引擎,Three.js 项目快速升级 Galacean 指南
前端·three.js
江城开朗的豌豆1 小时前
React应用优化指南:让我的项目性能“起飞”✨
前端·javascript·react.js
会飞的青蛙1 小时前
GIT 配置别名&脚本自动化执行
前端·git