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

微擎微网站开发营销推广的平台

微擎微网站开发,营销推广的平台,苍溪建设局网站,海外英文建站纯前端上传word,xlsx,ppt,在前端预览并下载成图片(预览效果可以,下载图片效果不太理想) 一.安装依赖二、主要代码 预览效果链接: https://github.com/501351981/vue-office 插件文档链接: https://501351981.github.io/vue-office/examples/d…

纯前端上传word,xlsx,ppt,在前端预览并下载成图片(预览效果可以,下载图片效果不太理想)

  • 一.安装依赖
  • 二、主要代码

预览效果链接: https://github.com/501351981/vue-office
插件文档链接: https://501351981.github.io/vue-office/examples/docs/config/

一.安装依赖

//docx文档预览组件
npm install @vue-office/docx vue-demi//excel文档预览组件
npm install @vue-office/excel vue-demi//pdf文档预览组件
npm install @vue-office/pdf vue-demi
//html生成图片
npm install html2canvas

二、主要代码

<template><div class="index"><div class="select-file"><input id="input" type="file" /></div><div class="file-preview" ref="excelContainer"><!-- <VueOfficeDocx v-if="src" style="height: 600px;" :src="src" /> --><VueOfficeExcel class="file-content" v-if="src" style="height: 1280px" :src="src" /><!-- <VueOfficePdf v-if="src" style="height: 600px" :src="src" /> --></div><button @click="generateImage">Generate Image</button></div>
</template>
<script>
// import VueOfficeDocx from '@vue-office/docx'
// import '@vue-office/docx/lib/index.css'import VueOfficeExcel from '@vue-office/excel'
import '@vue-office/excel/lib/index.css'// import VueOfficePdf from '@vue-office/pdf'import html2canvas from 'html2canvas'
export default {data() {return {src: '',}},components: {// VueOfficeDocx,VueOfficeExcel,//  VueOfficePdf},mounted() {this.addInputEventListener()},methods: {/*** application/msword;charset=utf-8* application/pdf;charset=utf-8* application/vnd.ms-excel*/addInputEventListener() {const input = document.querySelector('#input')input.addEventListener('input', e => {const fileBlob = e.target.files[0]// 第一种方式(通过window.URL.createObjectURL将Blob文件流转为一个路径)this.src = window.URL.createObjectURL(new Blob([fileBlob]))// 第二种方式(转为base64编码)const fileReader = new FileReader()fileReader.readAsDataURL(fileBlob)fileReader.onload = e => {this.src = e.target.result}// 第三种方式(获取到buffer)fileBlob.arrayBuffer().then(buffer => {this.src = buffer})})},generateImage() {const element = this.$refs.excelContainerhtml2canvas(element, { useCORS: true }).then(canvas => {const image = canvas.toDataURL('image/png')const link = document.createElement('a')link.href = imagelink.download = 'excel_image.png'link.click()}).catch(error => {console.error('Error generating image:', error)})},},
}
</script>
<style scoped>
.index {width: 100%;height: 100%;padding: 15px;box-sizing: border-box;
}
.select-file {width: 100%;height: 35px;border-bottom: 1px dashed #ccc;margin-bottom: 15px;
}
.file-preview {width: 100%;height: 100%;border: 1px dashed #007acc;
}
</style>

在这里插入图片描述

没了~

链接: https://www.jb51.net/article/278400.htm

http://www.ds6.com.cn/news/37386.html

相关文章:

  • 大兴智能网站建设哪家好广州抖音推广公司
  • 网站目录架构怎么做seo
  • 怎样做网站-百度指数是什么
  • 三河做网站网络营销顾问
  • 做个公司网站多少钱青岛seo精灵
  • 空间购买网站北京seo技术
  • 用虚拟机做网站服务器吗免费投放广告平台
  • 做网站的属于什么专业?百度网站搜索排名
  • 网站的形式企业网站设计价格
  • 做业精灵官方网站seo综合查询国产
  • 国外服务器vps昆明seo外包
  • 大学校园网站建设的百度小说排行榜第一名
  • 建行门户网站宁波网站关键词排名推广
  • 做网站应该注意百度官网电话客服24小时
  • 搭建电商平台方案索引擎优化 seo
  • 公司网站建设计划书软文自助发布平台系统
  • 手机网站怎么推广深圳seo优化电话
  • 做网站的风险合肥网络seo推广服务
  • 建设集团网站报告书线上营销方案
  • 网站做rss+wordpress做网站设计的公司
  • 网站运营人员岗位职责上海网站推广优化
  • 国内做国外代购在哪个网站seo按照搜索引擎的
  • wordpress复制一个英文版东莞有限公司seo
  • asp网站开门东莞seo网站排名优化公司
  • 自助建站什么意思浏览器打开
  • 丽水企业网站建设微信广告投放收费标准
  • 广州网站建设找新际seo电商运营是什么意思
  • 网站建设上公司seo推广营销网站
  • 网站下载系统如何做系统如何设计一个网页
  • 各类网站杭州seo关键词优化公司