Skip to content

RBarcode 条形码

条形码。

基础使用

code
tsx
import { RBarcode } from '@/components'

const Demo = () => {
  return <RBarcode text="123456789" />
}

回调函数

code
tsx
import { RBarcode } from '@/components'

const Demo = () => {
  const _success = () => {}

  const _error = () => {}

  const _finally = () => {}

  return (
    <>
      <RBarcode text="渲染成功" onSuccess={_success} onFinally={_finally} />
      <RBarcode text="渲染失败" onError={_error} onFinally={_finally} />
    </>
  )
}

props

名称类型默认值说明
widthstring | numberauto条形码宽度
heightstring | numberauto条形码高度
loadingbooleanfalse显示加载状态
barcodeRendersvg | canvascanvas渲染模式
textstringundefine条形码内容
optionsRBarcodeOptions{}渲染配置项
formatRBarcodeFormatCODE128条形码输出格式,该配置项优先级最高
watchTextbooleanfalse主动监听 text 内容变化,当内容变化时重新渲染条形码
onSuccess(currentText: string | undefine, format: RBarcodeFormat, option: RBarcodeOptions) => voidundefine渲染成功回调函数
onError(error: Error) => voidundefine渲染失败回调函数
onFinally() => voidundefine条形码渲染结束后执行的回调函数

Released under the MIT License.