ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import type { Options, Props } from './typing';
 
import { createVNode, render } from 'vue';
 
import { isClient } from '@jnpf/utils';
 
import ImgPreview from './Functional.vue';
 
let instance: null | ReturnType<typeof createVNode> = null;
export function createImgPreview(options: Options) {
  if (!isClient) return;
  const propsData: Partial<Props> = {};
  const container = document.createElement('div');
  Object.assign(propsData, { index: options.index || 0, scaleStep: 20, show: true }, options);
 
  instance = createVNode(ImgPreview, propsData);
  render(instance, container);
  document.body.append(container);
  return instance.component?.exposed;
}