1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| import Vue from "vue";
| import FilePreview from "@/components/FilePreview/index.vue";
|
| let instance = null;
|
| /**
| * 全局文件预览:图片、PDF
| * @param {Array|Object} files [{ name, url }] 或单个 { name, url }
| * @param {Number} index 默认选中下标
| */
| export default function previewFile(files, index = 0) {
| if (!instance) {
| const FilePreviewCtor = Vue.extend(FilePreview);
| instance = new FilePreviewCtor().$mount();
| document.body.appendChild(instance.$el);
| }
| instance.open(files, index);
| }
|
|