图片预览组件实例懒加载

master
chenjiajian 2023-04-27 19:00:58 +08:00
parent 24ab722877
commit d87517ae63
1 changed files with 8 additions and 2 deletions

View File

@ -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
}