文档
示例
import React, { useState, useEffect, useRef } from 'react';
import QRCode from 'qrcode';
function GenerateQrCode() {
const [codeInts] = useState(useRef(null));
useEffect(() => {
if (codeInts.current) {
new QRCode(codeInts.current, {
text: "xxx.com",
width: 128,
height: 128,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRCode.CorrectLevel.H
});
}
}, [codeInts]);
return (
<div ref={codeInts} />
);
}
export default GenerateQrCode;