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
DOMの画像化はおそらく、html2canvasがいいんじゃなかろうかと思った。 過去に画像化を使用した際のコードがあるから参考にして下さい。
import React, { useEffect } from 'react' import { Button, Container } from 'react-bootstrap' // Button追加 import html2canvas from 'html2canvas' type Props = { name:string } const MakePicture: React.FC<Props> = ( {name}) => { const makePicture = async () => { const elem = document.querySelector("#target") as HTMLElement; console.log(elem) html2canvas(elem, {scale:2,allowTaint:true}).then(function(canvas) { const a = document.createElement('a') const dataURI = canvas.toDataURL("image/png"); a.href = dataURI const name = name +'.png' a.download = name a.click() }); } return ( <> <Button className='mt-3' type='button' variant='primary' onClick={makePicture}>保存する</Button> {/* 追記 */} </> ) } export default MakePicture
The text was updated successfully, but these errors were encountered:
Be3751
Daiki-Shiraki
No branches or pull requests
DOMの画像化はおそらく、html2canvasがいいんじゃなかろうかと思った。
過去に画像化を使用した際のコードがあるから参考にして下さい。
The text was updated successfully, but these errors were encountered: