ScanInput

ScanInput sert à ajouter la prise en charge du scan à un champ de saisie.

Utilisation de base

Current value: -
import React, { useState } from 'react';
import { ScanInput } from '@nocobase/client-v2';
import { Space, Typography } from 'antd';

export default function ScanInputDemo() {
  const [value, setValue] = useState('');

  return (
    <Space direction="vertical" style={{ width: 360 }}>
      <ScanInput
        value={value}
        placeholder="Scan or input code"
        onChange={(next) => {
          if (typeof next === 'string') {
            setValue(next);
          } else {
            setValue(next.target.value);
          }
        }}
      />
      <Typography.Text type="secondary">
        Current value: {value || '-'}
      </Typography.Text>
    </Space>
  );
}

API

ParamètreTypeDescription
disableManualInputbooleanRendre le champ en lecture seule
enableScanbooleanParamètre réservé ; le bouton de scan est toujours rendu
formatsToSupportHtml5QrcodeSupportedFormats[]Formats de QR code ou code-barres pris en charge
onChange`(value: stringChangeEvent) => void`

Liens associés