You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
670 B
26 lines
670 B
import React from 'react';
|
|
import { QRCode, Button } from 'antd';
|
|
|
|
const downloadQRCode = () => {
|
|
const canvas = document.getElementById('myqrcode')?.querySelector<HTMLCanvasElement>('canvas');
|
|
if (canvas) {
|
|
const url = canvas.toDataURL();
|
|
const a = document.createElement('a');
|
|
a.download = 'QRCode.png';
|
|
a.href = url;
|
|
document.body.appendChild(a);
|
|
a.click();
|
|
document.body.removeChild(a);
|
|
}
|
|
};
|
|
|
|
const App: React.FC = () => (
|
|
<div id="myqrcode">
|
|
<QRCode value="https://ant.design/" style={{ marginBottom: 16 }} />
|
|
<Button type="primary" onClick={downloadQRCode}>
|
|
Download
|
|
</Button>
|
|
</div>
|
|
);
|
|
|
|
export default App;
|
|
|