@libeilong/react-photo-view
v0.0.1
Published
对 `react-photo-view` 的轻量封装,提供命令式图片预览 API。
Readme
@libeilong/react-photo-view
对 react-photo-view 的轻量封装,提供命令式图片预览 API。
安装
pnpm add @libeilong/react-photo-view应用入口引入样式(一次即可):
import '@libeilong/react-photo-view/index.css'使用
import { previewImages } from '@libeilong/react-photo-view'
previewImages({
items: [
{ url: 'https://example.com/a.jpg', intro: '图片 A' },
{ url: 'https://example.com/b.jpg', intro: '图片 B' },
],
current: 'https://example.com/a.jpg',
})items 也支持直接传 URL 字符串。无需在应用根节点挂载 Provider,首次调用时会自动创建预览宿主。
API
previewImages(opts)
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| items | (PreviewImageItem \| string)[] | 预览列表 |
| current | string | 当前展示的 URL |
| maskOpacity | number | 遮罩透明度,默认 0.75 |
