当前位置: 首页 > news >正文

做html网站模板下载地址抚州网络推广

做html网站模板下载地址,抚州网络推广,网站如何做3d产品,辽宁建设工程信息网新网站概述 在做项目的时候会遇到docx、xlsx、pdf等文件的在线预览需求,实现此需求可以有多种解决方式,本文基于vue-office实现纯前端的文件预览。 效果 如下图,分别为docx、xlsx、pdf三种类型的文件在线加载后的效果。你也可以访问官方预览网址…

概述

在做项目的时候会遇到docxxlsxpdf等文件的在线预览需求,实现此需求可以有多种解决方式,本文基于vue-office实现纯前端的文件预览。

效果

如下图,分别为docxxlsxpdf三种类型的文件在线加载后的效果。你也可以访问官方预览网址查看效果。
image.png

实现

1. 添加依赖

package.json文件中添加如下依赖,并通过命令npm i安装依赖。

{...,"dependencies": {"@vue-office/docx": "1.6.0","@vue-office/excel": "1.6.0","@vue-office/pdf": "1.6.0"},
}

2. 引入依赖

vue文件中引入依赖,示例代码如下:

//引入相关样式
import '@vue-office/docx/lib/index.css'
import '@vue-office/excel/lib/index.css'//引入VueOffice组件
import VueOfficeDocx from '@vue-office/docx'
import VueOfficeExcel from '@vue-office/excel'
import VueOfficePdf from '@vue-office/pdf'export default {components: {VueOfficeDocx,VueOfficeExcel,VueOfficePdf},
}

3. 使用组件

<template><div class="layout-file"><div class="layout-file-title">{{docx}}</div><vue-office-docx :src="docx" @rendered="rendered"/></div><div class="layout-file"><div class="layout-file-title">{{excel}}</div><vue-office-excel :src="excel" @rendered="rendered"/></div><div class="layout-file"><div class="layout-file-title">{{pdf}}</div><vue-office-pdf style="height: 100%;" :src="pdf" @rendered="rendered"/></div>
</template>

完整的实现代码如下:

<template><div class="layout-file"><div class="layout-file-title">{{docx}}</div><vue-office-docx :src="docx" @rendered="rendered"/></div><div class="layout-file"><div class="layout-file-title">{{excel}}</div><vue-office-excel :src="excel" @rendered="rendered"/></div><div class="layout-file"><div class="layout-file-title">{{pdf}}</div><vue-office-pdf style="height: 100%;" :src="pdf" @rendered="rendered"/></div>
</template><script>
//引入相关样式
import '@vue-office/docx/lib/index.css'
import '@vue-office/excel/lib/index.css'//引入VueOffice组件
import VueOfficeDocx from '@vue-office/docx'
import VueOfficeExcel from '@vue-office/excel'
import VueOfficePdf from '@vue-office/pdf'export default {components: {VueOfficeDocx,VueOfficeExcel,VueOfficePdf},data() {return {pdf: 'http://localhost:18081/doc.pdf',excel: 'http://localhost:18081/doc.xlsx',docx: 'http://localhost:18081/doc.docx',ppt: 'http://localhost:18081/doc.pptx'}},methods: {rendered() {console.log('rendered')}}
}
</script><style lang="scss" scoped>
.layout-file {width: calc(50% - 1rem);height: 50%;float: left;margin-top: 0.8rem;margin-right: 0.8rem;position: relative;border: 1px solid #f00;border-radius: 0.3rem;&:nth-child(1), &:nth-child(2) {margin-top: 0;}.layout-file-title {position: absolute;top: 0.5rem;right: 1.5rem;background-color: rgba(255,0,0,0.8);padding: 0.1rem 0.4rem;z-index: 99;color: #fff;border-radius: 0.3rem;font-size: 12px;}
}
</style>
http://www.ds6.com.cn/news/91602.html

相关文章:

  • 可以写代码的网站有哪些问题成都网站建设软件
  • 黔江做网站关键词怎么提取
  • 北京营销网站建设短视频营销方式有哪些
  • 做网站资源知乎推广宣传方式有哪些
  • mvc 做网站电商网站大全
  • 网站宣传的优点网络营销推广策划的步骤是什么
  • 利辛做网站seo页面排名优化
  • 网站建设主机个人网页怎么做
  • 在百度怎么建立自己的网站吗做网站需要哪些技术
  • 白酒营销网站百度手机助手下载免费安装
  • 怎么做网站自己当站长广州线下培训机构停课
  • web网站开发流程图客源软件哪个最好
  • 公司网站seo外包西安seo优化培训
  • 阿里云做网站吗seo排名优化价格
  • 云点wordpress上海优化外包
  • 做网站关键词要懂代码么百度竞价是seo还是sem
  • 中国数控机床网seo知识点
  • 卡盟做网站最好用的免费建站
  • 自己做的网站怎么让别人能访问爱站长尾关键词挖掘工具
  • 绵阳的网站建设网络营销推广公司名称
  • 海口市住房和城乡建设局网站seo网站优化平台
  • 建设个人网银网站快刷网站
  • 怎么样检查网站有没有做全站301百度官方网站网址
  • 北京住房与建设部网站pc端网页设计公司
  • 做网站pdf不能预览怎么推广软件
  • 网络有限公司名字大全站长工具seo综合查询网
  • 深圳品牌做网站龙岩seo
  • 做网站宣传的公司世界搜索引擎公司排名
  • 自己做的网站能放到网上么精准网络营销推广
  • 建设银行网站e动终端如何做网络推广外包