diff --git a/src/image/preview.js b/src/image/preview.js index e127ace..42120f0 100644 --- a/src/image/preview.js +++ b/src/image/preview.js @@ -262,15 +262,21 @@ class ImagePreview extends Component { } } ImagePreview.reg('image-preview') -const instance = new ImagePreview() -document.body.appendChild(instance) + +let instance = null window.imagePreview = function (options) { + if (!instance) { + instance = new ImagePreview() + document.body.appendChild(instance) + } + if (Array.isArray(options)) { instance.list = options } else { Object.assign(instance, options) } + instance.visible = true return instance }