前端实现文件在线预览txt,pdf,doc,xls,ppt几种格式

使用iframe标签

1.text,pdf的文件预览

<iframe class="filename" :src="文件的地址" width='100%' height='600' frameborder='1' ></iframe>

2.doc,xls,ppt等office的预览

<iframe class="filename"  :src="https://view.officeapps.live.com/op/view.aspx?src=后面是文件的地址" width='100%' height='600' frameborder='1' ></iframe>

这些格式之外的文件没有办法预览如RAR,ZIP,会直接提醒你下载,基本完成预览的需求,重点就是预览文件前,把office文件的路径配置下,使用微软提供的在线office预览

猜你喜欢

转载自www.cnblogs.com/leileilei/p/10755611.html