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

做网站挣钱快吗正确的企业邮箱格式

做网站挣钱快吗,正确的企业邮箱格式,北京市建设资格注册中心网站,做网站大概需要几步若要将包含 ElementUI 组件数据和多个 ECharts 图表的数据转换为 PDF 文档,可结合 html2canvas、jspdf 以及 dom-to-image 来实现。其中,html2canvas 和 dom-to-image 可将 ECharts 图表转换为图片,jspdf 则用于生成 PDF 文档。对于 ElementU…

若要将包含 ElementUI 组件数据和多个 ECharts 图表的数据转换为 PDF 文档,可结合 html2canvasjspdf 以及 dom-to-image 来实现。其中,html2canvasdom-to-image 可将 ECharts 图表转换为图片,jspdf 则用于生成 PDF 文档。对于 ElementUI 组件数据,可直接使用 HTML 内容添加到 PDF 中。

实现思路

  1. 准备 HTML 结构:创建包含 ElementUI 组件数据和 ECharts 图表的 HTML 结构。
  2. 转换 ECharts 图表为图片:使用 html2canvasdom-to-image 将 ECharts 图表转换为图片。
  3. 生成 PDF 文档:使用 jspdf 创建 PDF 文档,先添加 ElementUI 组件数据的 HTML 内容,再添加 ECharts 图表的图片。

代码示例

<template><div><!-- ElementUI 组件数据 --><div id="elementui-data"><el-table :data="tableData" style="width: 100%"><el-table-column prop="date" label="日期"></el-table-column><el-table-column prop="name" label="姓名"></el-table-column><el-table-column prop="address" label="地址"></el-table-column></el-table></div><!-- ECharts 图表 --><div id="echarts-charts"><div id="chart1" style="width: 600px; height: 400px;"></div><div id="chart2" style="width: 600px; height: 400px;"></div></div><el-button @click="exportToPDF">导出为 PDF</el-button></div>
</template><script setup>
import { ref, onMounted } from 'vue';
import * as echarts from 'echarts';
import html2canvas from 'html2canvas';
import jsPDF from 'jspdf';
import 'element-plus/dist/index.css';
import { ElTable, ElTableColumn, ElButton } from 'element-plus';// ElementUI 表格数据
const tableData = ref([{date: '2023-05-01',name: '张三',address: '北京市朝阳区'},{date: '2023-05-02',name: '李四',address: '上海市浦东新区'}
]);// 初始化 ECharts 图表
onMounted(() => {const chart1Dom = document.getElementById('chart1');const chart1 = echarts.init(chart1Dom);const option1 = {xAxis: {type: 'category',data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']},yAxis: {type: 'value'},series: [{data: [120, 200, 150, 80, 70, 110, 130],type: 'bar'}]};chart1.setOption(option1);const chart2Dom = document.getElementById('chart2');const chart2 = echarts.init(chart2Dom);const option2 = {xAxis: {type: 'category',data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']},yAxis: {type: 'value'},series: [{data: [80, 150, 120, 200, 130, 70, 110],type: 'bar'}]};chart2.setOption(option2);
});// 导出为 PDF
const exportToPDF = async () => {const pdf = new jsPDF();const elementuiData = document.getElementById('elementui-data');const echartsCharts = document.getElementById('echarts-charts');// 添加 ElementUI 数据到 PDFpdf.html(elementuiData, {callback: function (pdf) {// 添加分页pdf.addPage();// 转换 ECharts 图表为图片并添加到 PDFconst convertChartsToImages = async () => {const chartElements = echartsCharts.querySelectorAll('[id^="chart"]');for (const chartElement of chartElements) {const canvas = await html2canvas(chartElement);const imgData = canvas.toDataURL('image/png');const imgProps = pdf.getImageProperties(imgData);const pdfWidth = pdf.internal.pageSize.getWidth();const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width;pdf.addImage(imgData, 'PNG', 0, pdf.getCursorPosition().y, pdfWidth, pdfHeight);// 若图片高度超出页面,添加新页面if (pdf.getCursorPosition().y + pdfHeight > pdf.internal.pageSize.height) {pdf.addPage();}}// 保存 PDFpdf.save('mixed_content.pdf');};convertChartsToImages();}});
};
</script>    

代码解释

  1. HTML 结构:包含一个 ElementUI 表格和两个 ECharts 图表,以及一个导出按钮。
  2. 初始化 ECharts 图表:在 onMounted 钩子中初始化两个 ECharts 图表。
  3. 导出为 PDF
    • 创建 jsPDF 实例。
    • 使用 pdf.html 方法将 ElementUI 数据添加到 PDF 中。
    • 转换 ECharts 图表为图片,并添加到 PDF 中。
    • 若图片高度超出页面,添加新页面。
    • 保存 PDF 文件。

注意事项

  • 要确保已安装 element-plusechartshtml2canvasjspdf 依赖。
  • 可根据实际需求调整 ECharts 图表和 ElementUI 组件的配置。

文章转载自:

http://abiqyDLU.prgdy.cn
http://jPOKw75n.prgdy.cn
http://plwVbrCj.prgdy.cn
http://rofyGfZc.prgdy.cn
http://GKD58Iu2.prgdy.cn
http://GihKHxbJ.prgdy.cn
http://TMFKBYai.prgdy.cn
http://mxRhYU1S.prgdy.cn
http://LFnkoH2s.prgdy.cn
http://oE4LW6q9.prgdy.cn
http://tCQPzEGe.prgdy.cn
http://EB9OTrLO.prgdy.cn
http://skuJtj2k.prgdy.cn
http://psDmxBXC.prgdy.cn
http://fDqcm78e.prgdy.cn
http://qRM7qahr.prgdy.cn
http://mFRekeVs.prgdy.cn
http://VsfgC0eF.prgdy.cn
http://lhQVGLhM.prgdy.cn
http://GyVBKPqv.prgdy.cn
http://xAxMNPWJ.prgdy.cn
http://Cez14tTW.prgdy.cn
http://buT6Utg0.prgdy.cn
http://DkjvkLiD.prgdy.cn
http://WFH2DMDS.prgdy.cn
http://Wg1nVL4Q.prgdy.cn
http://QkejBQK0.prgdy.cn
http://tnV8kS4K.prgdy.cn
http://oZcS7IrF.prgdy.cn
http://F8JucWZ7.prgdy.cn
http://www.dtcms.com/wzjs/651077.html

相关文章:

  • 企业建设网站的步骤是什么意思云南建设投资集团网站首页
  • 深圳网站建设公司乐云seo电子商务网站的网络营销策略分析
  • 合作社网站模板厦门网站开发网络公司
  • wordpress json网站关键词优化是什么
  • 关于手表的网站wordpress不能上传
  • 曲靖网站微信建设网站建站工具有哪些
  • 全部免费网站软件微信小程序生成平台系统
  • 网站设计现状巴中微信开发 做网站
  • 网站建设策划书范文六篇精选枣庄住房和城市建设局网站
  • 网站平台结构网站建设管理理论
  • net做网站遇到的问题深圳品牌防伪网
  • 校园网上零售网站建设方案网站开发方式包括
  • 免费给人做网站的用dw做一个简单的网页
  • 玉林网站推广网站外链如何建设最有用
  • 广州 网站定制济南建站公司价格
  • 网站模板安装教程关于科技的名言
  • 太原网站建设王道下拉惠门户网站免费建设
  • 张家口网站建设哪家服务好国外营销型网站建设
  • 购物网站设计会员管理模块品牌宝正式推出免费个人网站认证
  • 兰州市建设厅网站wordpress自动提取标签
  • 合肥网站搭建Html5做旅游网站的设计思路
  • 贵阳专业做网站的公司有哪些晚上必看的正能量网站
  • 行业协会网站模板广州智能建站软件
  • 方舟未来网站建设广东东莞石碣今天新闻
  • 网站源码整站下载中国十大设计名校
  • 二手书交易网站开发与设计国内h5网站欣赏
  • 新余建设网站wordpress win主题
  • mvc5 网站开发之美 pdf区域城市分站网站怎么做
  • 免费网站开发软件有哪些专业做鞋子的网站
  • 网站制作自己做微信小程序制作公司排行榜