vue预览word,excel,pptx,pdf文件
1、做word,excel,pptx的预览,要先确定文件路径访问是通过域名的url来预览,不可以通过IP的url来访问
先把文件路径的url进行url编码(encodeURIComponent)
let router = 'https://aaaaaa.com/file/download?filename=file.obj_id' //文件路径let url = encodeURIComponent(routeUrl)
然后用Office Web Viewer的路径接口
http://view.officeapps.live.com/op/view.aspx?src=
把两个拼接在一起
let officeUrl = 'http://view.officeapps.live.com/op/view.aspx?src='+urlwindow.open(officeUrl,'_target')
这样就可以预览word,excel,pptx文件了
完整的代码
let routeUrl = 'https://aaaaaa.com/file/download?filename=file.obj_id'let url = encodeU