给你:应该相当清楚…
class App extends React.Component {
constructor(props) {
super(props);
this.state = { canvasArray: [] };
this.captureRef = React.createRef();
}
getScreenshotHandler = () => {
html2canvas(this.captureRef.current).then(canvas =>
this.setState({
canvasArray: [canvas.toDataURL(), ...this.state.canvasArray],
}),
);
};
renderCanvas = () => {
return this.state.canvasArray.map((canvas, i) => {
return ;
});
};
render() {
return (
This enitre div
will be captured
Get Screenshot!
Your screenshots will be availbale below:
{this.renderCanvas()}
);
}
}