吉安感知网项目-前端
shuishen
5 days ago 6e88705bd5b443a259b24c17c8a299765d059d96
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<template>
    <el-dialog
        class="gd-dialog"
        v-model="visible"
        title="预览"
        @closed="visible = false"
        destroy-on-close
        fullscreen
        :close-on-click-modal="false"
    >
        <VueOfficeDocx
            v-if="type === 'docx'"
            :src="src"
            style="height: 100%;width: 100%"
            @rendered="onRendered"
            @error="onError"
        />
        <VueOfficePdf
            v-else
            :src="src"
            style="height: 100%;width: 100%"
            @rendered="onRendered"
            @error="onError"
        />
    </el-dialog>
</template>
 
 
<script setup>
import VueOfficeDocx from '@vue-office/docx'
import VueOfficePdf from '@vue-office/pdf'
import '@vue-office/docx/lib/index.css' // 必须引入样式
 
const visible = ref(false)
const props = defineProps({
  src: {
    default: '',
  },
    type:{
        type: String,
        default: 'docx'
    }
})
 
function onRendered() {
    console.log("文档渲染完成")
}
 
function onError() {
    console.log("文档渲染失败")
}
</script>
 
 
 
<style scoped lang="scss"></style>