mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 12:39:49 +08:00
1 line
1.4 KiB
JavaScript
1 line
1.4 KiB
JavaScript
(("undefined"!=typeof globalThis?globalThis:self).makoChunk_antd=("undefined"!=typeof globalThis?globalThis:self).makoChunk_antd||[]).push([["db8c2227"],{db8c2227:function(e,t,o){"use strict";o.d(t,"__esModule",{value:!0}),o.d(t,"default",{enumerable:!0,get:function(){return s;}});var a=o("777fffbe"),n=o("f19d2b93");o("8f75fd04");var d=a._(o("5b220c3d")),l=o("a9d1a279");function i(e,t){let o=document.createElement("a");o.download=t,o.href=e,document.body.appendChild(o),o.click(),document.body.removeChild(o);}let c=()=>{var e;let t=null===(e=document.getElementById("myqrcode"))||void 0===e?void 0:e.querySelector("canvas");t&&i(t.toDataURL(),"QRCode.png");},r=()=>{var e;let t=null===(e=document.getElementById("myqrcode"))||void 0===e?void 0:e.querySelector("svg"),o=new Blob([new XMLSerializer().serializeToString(t)],{type:"image/svg+xml;charset=utf-8"});i(URL.createObjectURL(o),"QRCode.svg");};var s=()=>{let[e,t]=d.default.useState("canvas");return(0,n.jsxs)(l.Space,{id:"myqrcode",direction:"vertical",children:[(0,n.jsx)(l.Segmented,{options:["canvas","svg"],value:e,onChange:t}),(0,n.jsxs)("div",{children:[(0,n.jsx)(l.QRCode,{type:e,value:"https://ant.design/",bgColor:"#fff",style:{marginBottom:16},icon:"https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"}),(0,n.jsx)(l.Button,{type:"primary",onClick:"canvas"===e?c:r,children:"Download"})]})]});};}}]); |