Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【缺陷】modern-screenshot 无法截图 AntD Icon 组件 #42

Closed
linhuiw opened this issue Aug 25, 2023 · 4 comments
Closed

【缺陷】modern-screenshot 无法截图 AntD Icon 组件 #42

linhuiw opened this issue Aug 25, 2023 · 4 comments

Comments

@linhuiw
Copy link

linhuiw commented Aug 25, 2023

问题描述

modern-screenshot 无法截图 AntD Icon 组件引入 iconfont.cn 文件 生成的 Icon,直接截图空白。

Steps To Reproduce

Playground for https://codesandbox.io

Your Environment

  • modern-screenshot: [e.g. 4.4.9]
  • Browser: [e.g. chrome 111.0.5563.64]

修复方案

看起来跟 html-to-image 这个方案有关?
bubkoo/html-to-image#393

看起来代码 读了 href 属性的值,没有读 xlink:href 属性的值

@qq15725
Copy link
Owner

qq15725 commented Aug 25, 2023

移除 XML 异常属性名的时候把属性名含 : 的也去掉了,现在应该正常了

https://codesandbox.io/s/modern-screenshot-wu-fa-jie-tu-shi-yong-iconfont-cn-de-tu-biao-forked-sdqc5y?file=/demo.tsx

@qq15725 qq15725 closed this as completed Aug 25, 2023
@linhuiw
Copy link
Author

linhuiw commented Aug 25, 2023

image

看起来问题并没有修复 🤨

@qq15725
Copy link
Owner

qq15725 commented Aug 25, 2023

需要等待 symbol 在 DOM 树中才能截图

image
setTimeout(() => {
  domToPng(document.querySelector("#icons")).then((dataUrl) => {
    setImg(dataUrl);
  });
}, 2000);

https://codesandbox.io/s/modern-screenshot-wu-fa-jie-tu-shi-yong-iconfont-cn-de-tu-biao-forked-sdqc5y?file=/demo.tsx

可以自己适配下时机

@linhuiw
Copy link
Author

linhuiw commented Aug 25, 2023

明白了,👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants