边界限制

This commit is contained in:
rickcole 2020-06-08 12:49:12 +08:00
parent c9fce11f38
commit fa1ce6bc7c

View File

@ -39,20 +39,27 @@ export default class QRCode extends React.Component<QRCodeProps, any> {
classPrefix: ns
} = this.props;
const finalValue = filter(value, data, '| raw');
return (
<div className={cx(`${ns}QrCode`, className)}>
{value ? (
{!finalValue ? (
<span className={`${ns}QrCode--placeholder`}>{placeholder}</span>
) : finalValue.length > 2953 ? (
// https://github.com/zpao/qrcode.react/issues/69
<span className="text-danger">
2953
</span>
) : (
<QrCode
className={qrcodeClassName}
value={filter(value, data, '| raw')}
value={finalValue}
renderAs={'svg'}
size={codeSize}
bgColor={backgroundColor}
fgColor={foregroundColor}
level={level || 'L'}
/>
) : (
<span className={`${ns}QrCode--placeholder`}>{placeholder}</span>
)}
</div>
);