From d87517ae6301462d67db54580e9a7688d5509e88 Mon Sep 17 00:00:00 2001 From: chenjiajian <770230504@qq.com> Date: Thu, 27 Apr 2023 19:00:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E9=A2=84=E8=A7=88=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=AE=9E=E4=BE=8B=E6=87=92=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/image/preview.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 }