最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

reactjs - How can I convert an HTML element or React node into an SVG or image? - Stack Overflow

programmeradmin1浏览0评论

I am working on a project where I gather data from a user and retrieve stats from their other publicly accessible profiles. Based on this, I generate profile cards or images to display that data.

The challenge I’m facing is that I’m able to fetch the user’s details using API calls, but I’m struggling to convert those details into images. I’ve tried using libraries like html-2-image and dom-to-image, but I encountered an issue. In the case of html-2-image, the HTML needs to be rendered in the document to generate the image. However, I don’t want the HTML to be visible to the user. To work around this, I tried setting the display to "none," but then neither html-2-image nor dom-to-image seems to work.

I came across some references and articles (like the one on StackOverflow) here, and I’m wondering if learning SVG creation is necessary to achieve this.

Can anyone suggest a solution or guide me in the right direction?

发布评论

评论列表(0)

  1. 暂无评论