image preview

This commit is contained in:
cookfront
2017-03-05 16:57:50 +08:00
parent f224cda4f2
commit 8856af91fd
7 changed files with 102 additions and 21 deletions
@@ -0,0 +1,31 @@
import Vue from 'vue';
import ImagePreview from './image-preview.vue';
import merge from 'src/utils/merge';
let instance;
const ImagePreviewConstructor = Vue.extend(ImagePreview);
const initInstance = () => {
instance = new ImagePreviewConstructor({
el: document.createElement('div')
});
};
var ImagePreviewBox = image => {
if (!instance) {
initInstance();
}
if (!instance.value) {
instance.image = image;
document.body.appendChild(instance.$el);
Vue.nextTick(() => {
instance.value = true;
});
}
};
export default ImagePreviewBox;