We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
// 抓取指定的 div,產生 base64 格式圖片 // 之所以重複二次,下一段的注意事項會解釋 const el = document.getElementById('xxx'); const config = { quality: 1, style: { "filter": "grayscale(100%)" } };
//原本這裡呼叫config的時候 名字打得跟宣告的地方不同 const dataUriTemp = await domtoimage.toPng(el, config).then(dataUrl => dataUrl); const dataUri = await domtoimage.toPng(el, config).then(dataUrl => dataUrl);
// 下載圖片 const link = document.createElement('a'); const filename = 'Demo.png'; link.download = filename; link.href = dataUri; link.click();
The text was updated successfully, but these errors were encountered:
哦對,沒發現放 Demo Code 的時候寫錯,不過 GitHub 的程式碼是寫對的。 當時製作時必須寫二遍才有圖,剛測試程式碼不變,只寫一次也有圖,神奇。
Sorry, something went wrong.
No branches or pull requests
正確版本
// 抓取指定的 div,產生 base64 格式圖片
// 之所以重複二次,下一段的注意事項會解釋
const el = document.getElementById('xxx');
const config = {
quality: 1,
style: { "filter": "grayscale(100%)" }
};
//原本這裡呼叫config的時候 名字打得跟宣告的地方不同
const dataUriTemp = await domtoimage.toPng(el, config).then(dataUrl => dataUrl);
const dataUri = await domtoimage.toPng(el, config).then(dataUrl => dataUrl);
// 下載圖片
const link = document.createElement('a');
const filename = 'Demo.png';
link.download = filename;
link.href = dataUri;
link.click();
The text was updated successfully, but these errors were encountered: