~得空写一下~
技术栈:vue2+elementUI
1.新建组件previewFile.vue
<template>
<div :class="['dialog-box']">
<el-dialog
:title="`${file.title}文件预览`"
:visible.sync="file.dialogVisible"
:before-close="handleClose"
width=""
top="0"
>
<div>
<iframe
class="child"
frameborder="0"
:src="'http://view.xdocin.com/xdoc?_xdoc=' + file.fileurl"
:style="{ height: height }"
/>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
props: {
file: {
type: Object,
default: function () {
return {
fileurl: "",
dialogVisible: false,
title: "",
};
},
},
},
data() {
return {
height: window.innerHeight - 120 + "px",
dialogVisible: false,
};
},
methods: {
handleClose() {
this.file.dialogVisible