提交 | 用户 | 时间
|
820397
|
1 |
import ImageViewer from './src/ImageViewer.vue' |
H |
2 |
import { isClient } from '@/utils/is' |
|
3 |
import { createVNode, render, VNode } from 'vue' |
|
4 |
import { ImageViewerProps } from './src/types' |
|
5 |
|
|
6 |
let instance: Nullable<VNode> = null |
|
7 |
|
|
8 |
export function createImageViewer(options: ImageViewerProps) { |
|
9 |
if (!isClient) return |
|
10 |
const { |
|
11 |
urlList, |
|
12 |
initialIndex = 0, |
|
13 |
infinite = true, |
|
14 |
hideOnClickModal = false, |
|
15 |
teleported = false, |
|
16 |
zIndex = 2000, |
|
17 |
show = true |
|
18 |
} = options |
|
19 |
|
|
20 |
const propsData: Partial<ImageViewerProps> = {} |
|
21 |
const container = document.createElement('div') |
|
22 |
propsData.urlList = urlList |
|
23 |
propsData.initialIndex = initialIndex |
|
24 |
propsData.infinite = infinite |
|
25 |
propsData.hideOnClickModal = hideOnClickModal |
|
26 |
propsData.teleported = teleported |
|
27 |
propsData.zIndex = zIndex |
|
28 |
propsData.show = show |
|
29 |
|
|
30 |
document.body.appendChild(container) |
|
31 |
instance = createVNode(ImageViewer, propsData) |
|
32 |
render(instance, container) |
|
33 |
} |