百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-native-lightbox

> 编程语言
开源

React Native 的全屏灯箱弹出窗口中的图片等

2.8K stars0 点赞1 次浏览
访问官网GitHub

工具介绍

React Native 的全屏灯箱弹出窗口中的图片等

React-native-lightbox

安装

bash
yarn add react-native-lightbox

用法

navigator 属性是可选的,但在 iOS 上建议使用,请参阅下一节了解 Navigator 配置。

javascript
import Lightbox from 'react-native-lightbox';

const LightboxView ({ navigator }) => (
  <Lightbox navigator={navigator}>
    <Image
      style={{ height: 300 }}
      source={{ uri: 'http://knittingisawesome.com/wp-content/uploads/2012/12/cat-wearing-a-reindeer-hat1.jpg' }}
    />
  </Lightbox>
);

Navigator 设置/Android 支持

为了支持 Android,你必须传入一个 Navigator 的引用,因为 Android 尚不支持 Modal 组件,且该组件不在官方待办事项列表中。请参阅 Example 项目以获取完整示例。

javascript
const renderScene = (route, navigator) => {
  const Component = route.component;

  return (
    <Component navigator={navigator} route={route} {...route.passProps} />
  );
};

const MyApp = () => (
  <Navigator
    ref="navigator"
    style={{ flex: 1 }}
    renderScene={renderScene}
    initialRoute={{
      component: LightboxView,
    }}
  />
);

属性

属性 类型 描述
activeProps object 可选属性集,应用于灯箱模式下的内容组件。可用于应用自定义样式或更高分辨率的图像源。
renderHeader(close) function 自定义头部,替代默认的带 X 按钮的头部
renderContent function 自定义灯箱内容,替代默认的子内容
willClose function 在灯箱关闭前触发
onClose function 在灯箱关闭时触发
onOpen function 在灯箱打开时触发
didOpen function 在灯箱打开后触发
underlayColor string 可触摸背景的颜色,默认为 black
backgroundColor string 灯箱背景的颜色,默认为 black
swipeToDismiss bool 启用通过向上或向下滑动来关闭全屏模式的手势,默认为 true。
springConfig object Animated.spring 配置,默认为 { ten

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言