# 在线预览Office 微软接口
<template>
<el-button @click="previewOffice">预览</el-button>
<el-dialog width="90%" v-model="state.dialogTableVisible" title="Office 预览">
<iframe class="w-1/1 h-480px" :src="state.officeUrl"></iframe>
</el-dialog>
</template>
<script lang="ts" setup>
import { reactive } from 'vue'
const state = reactive({
dialogTableVisible:false,
officeUrl:''
})
const previewOffice = ()=>{
let routeUrl = 'https://file.zengweihao.cn/upload/2022-09-27/1664244153720.docx'
let url = encodeURIComponent(routeUrl)
state.officeUrl = 'http://view.officeapps.live.com/op/view.aspx?src=' + url
state.dialogTableVisible = true
}
// window.open(officeUrl)
</script>
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25