想要实现文件在线预览 有一个简单粗暴很直接的方法 话不多说上图
效果在代码下方
这种方法简单粗暴,PDF和txt格式的文件可以直接在浏览器预览直接安排上连接即可,
注:这个连接必须是公开的,没有跨域限制的.
docx和excel格式的文件使用微软的方法也可以直接在浏览器中显示
<el-button @click="pdf()">浏览器pdf预览</el-button>
<el-button @click="word()">浏览器word预览</el-button>
<el-button @click="biaoge()">浏览器表格预览</el-button>
<el-button @click="txt()">浏览器txt预览</el-button>
txt(){
window.open(this.txtURL)
},
biaoge() {
window.open("https://view.officeapps.live.com/op/view.aspx?src=" + this.biaogeURL)
},
word() {
window.open("https://view.officeapps.live.com/op/view.aspx?src=" + this.wordURL)
},
pdf() {
window.open(this.pdfURL)
},