-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee56698
commit 4d10803
Showing
5 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
template | ||
src/components/meKeepAlive | ||
dist | ||
vite.config.ts.* | ||
src/components/meVxeTable/vxe-table-plugin-element | ||
vite.config.ts.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ElImageViewer } from 'element-plus'; | ||
import { createVNode, render } from 'vue'; | ||
//函数组件只能以服务的方式调用 | ||
export function createImageViewer(props: ComponentProps<typeof ElImageViewer>) { | ||
const container = document.createElement('div'); | ||
const vnode = createVNode( | ||
ElImageViewer, | ||
Object.assign( | ||
{ | ||
onClose: function () { | ||
render(null, container); | ||
if (typeof props.onClose === 'function') { | ||
props.onClose.call(this); | ||
} | ||
}, | ||
}, | ||
props, | ||
), | ||
); | ||
render(vnode, container); | ||
// instances will remove this item when close function gets called. So we do not need to worry about it. | ||
document.body.appendChild(container.firstElementChild!); | ||
return vnode; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { RouteRecordRaw } from 'vue-router'; | ||
export const routes: RouteRecordRaw[] = [ | ||
{ | ||
path: 'imageViewer', | ||
component: () => import('@/views/components/imageViewer.vue'), | ||
meta: { title: '图片预览' }, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<template> | ||
<div class="image-viewer"> | ||
<el-button @click="show()"> 预览 </el-button> | ||
</div> | ||
</template> | ||
<script setup lang="ts" name="ImageViewer"> | ||
import { createImageViewer } from '@/components/service/meImageViewer'; | ||
const show = () => | ||
createImageViewer({ | ||
urlList: [ | ||
'https://scpic.chinaz.net/Files/pic/pic6/pic1281.jpg', | ||
'https://scpic.chinaz.net/files/pic/pic9/202009/apic27858.jpg', | ||
'https://tse3-mm.cn.bing.net/th/id/OIP-C.n0_p3rYRuofABd3XudbZnAHaEo?pid=ImgDet&rs=1', | ||
], | ||
}); | ||
</script> |