栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

将组件重新打包为PNG

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

将组件重新打包为PNG

通过研究“图表”组件,我能够解决我的问题。图表在包装器下呈现为SVG,因此我要做的就是正确转换以保存为HTML或SVG

// Exports the graph as embedded JS or PNGexportChart(asSVG) {    // A Recharts component is rendered as a div that contains namely an SVG    // which holds the chart. We can access this SVG by calling upon the first child/    let chartSVG = ReactDOM.findDOMNode(this.currentChart).children[0];    if (asSVG) {        let svgURL = new XMLSerializer().serializeToString(chartSVG);        let svgBlob = new Blob([svgURL], {type: "image/svg+xml;charset=utf-8"});        FileSaver.saveAs(svgBlob, this.state.uuid + ".svg");    } else {        let svgBlob = new Blob([chartSVG.outerHTML], {type: "text/html;charset=utf-8"});        FileSaver.saveAs(svgBlob, this.state.uuid + ".html");    }}

我正在使用FileSaver.js作为保存提示。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/616481.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号