mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-15 08:59:15 +08:00
b534c1ecb4
* fet: QRCode support type(renderAs) * fet: QRCode support type(renderAs) * fet: QRCode support type(renderAs) * fet: QRCode support type(renderAs) * fix: Improve type.md, export QRProps * Update components/qrcode/demo/type.md Co-authored-by: lijianan <574980606@qq.com> * Update components/qrcode/index.tsx Co-authored-by: lijianan <574980606@qq.com> * fix: qrCodeProps * fix: qrcode snap * Update components/qrcode/demo/type.md Co-authored-by: lijianan <574980606@qq.com> * fix: QRCode docs * fix: QRCode demo * Update components/qrcode/demo/download.tsx Co-authored-by: lijianan <574980606@qq.com> * Update components/qrcode/demo/download.tsx Co-authored-by: lijianan <574980606@qq.com> * fix: QRCode snap * fix: QRCode snap * fix: 恢复下载示例 --------- Co-authored-by: lijianan <574980606@qq.com>
27 lines
670 B
TypeScript
27 lines
670 B
TypeScript
import { Button, QRCode } from 'antd';
|
|
import React from 'react';
|
|
|
|
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;
|