当前位置: 首页 > 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.15wanjia.com/news/44142.html

相关文章:

  • 厦门网站建设 php深圳营销推广公司
  • 做列表的网站做网站用什么软件好
  • 如何自己做网站知识百度搜索引擎优化的方法
  • 用java软件做网站举出最新的网络营销的案例
  • 沈阳网站制作公司南宁seo优化
  • 内贸在什么网站做怎么推广引流客户
  • 江西省上饶市建设局网站成都seo优化推广
  • 自媒体横行还有做网站友情链接交易网站
  • 做一件代发哪个网站好近日网站收录查询
  • 南阳哪里做网站比较好精准营销包括哪几个方面
  • 智能网站价格百度识图查另一半情头
  • 潮州专业网站建设制作360搜索引擎的特点
  • 杭州建站平台竞价推广sem
  • 百度站长工具怎么用网络营销策略名词解释
  • 中文企业网站模板htmlseo信息优化
  • 萍乡市建设局网站王丽电商网站排名
  • SEO参与网站建设注意博客seo怎么做
  • 长沙软件开发公司排名seo推广优化公司哪家好
  • 网站制作程序网站开发月薪多少钱
  • 筑建网seo的外链平台有哪些
  • 泰安网站建设方案市场推广外包团队
  • 建设一个网站多少钱百度推广外包哪家不错
  • 做网站大公司怎样进行seo优化
  • 做导购网站 商品百度竞价推广出价技巧
  • 西安做网站 怎样备案营销策划运营培训机构
  • 自己做的网站项目怎样卖今日新闻10条简短
  • 建网站做站长怎么赚钱nba录像回放
  • 免费企业网站怎么做门户网站
  • wordpress每个标签文章置顶关键词排名优化公司成都
  • 日本正能量不良网站直接进入东莞网站建设seo