@adrianso/react-native-barcode-builder

中文文档
1.0.13发布于 2024/12/20MITTypeScriptCommonJS近 30 天下载 2927

React Native component to generate barcodes.

原始使用文档
文档目录4 节
  1. Getting started
  2. Step 1
  3. Step 2
  4. Properties

@adrianso/react-native-barcode-builder

React Native component to generate barcodes.

Uses JsBarcode for encoding of data.

Uses @react-native-community/react-native-svg instead of @react-native-community/art.

Getting started

Step 1

Install @adrianso/react-native-barcode-builder and dependencies:

npm install @adrianso/react-native-barcode-builder react-native-svg

or

yarn add @adrianso/react-native-barcode-builder react-native-svg

Step 2

Start using the component

import Barcode from '@adrianso/react-native-barcode-builder';

<Barcode value="Hello World" format="CODE128" />;

or you can invoke the barcodeToSvg function to convert any barcode to and SVG string

import { barcodeToSvg } from '@adrianso/react-native-barcode-builder';

const svg = barcodeToSvg({
  value: 'Hello world!',
});

/* svg will now have the following value
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 167 100" preserveAspectRatio="xMinYMin slice">
        <path d="M0,0h2v100h-2z M3,0h1v100h-1z M6,0h1v100h-1z M11,0h2v100h-2z M16,0h1v100h-1z M18,0h1v100h-1z M22,0h1v100h-1z M24,0h2v100h-2z M28,0h1v100h-1z M33,0h2v100h-2z M37,0h1v100h-1z M39,0h1v100h-1z M44,0h2v100h-2z M48,0h1v100h-1z M50,0h1v100h-1z M55,0h1v100h-1z M59,0h4v100h-4z M64,0h1v100h-1z M66,0h2v100h-2z M69,0h2v100h-2z M73,0h2v100h-2z M77,0h3v100h-3z M81,0h1v100h-1z M85,0h2v100h-2z M88,0h1v100h-1z M92,0h4v100h-4z M97,0h1v100h-1z M99,0h1v100h-1z M102,0h1v100h-1z M105,0h4v100h-4z M110,0h2v100h-2z M114,0h1v100h-1z M116,0h1v100h-1z M121,0h1v100h-1z M126,0h1v100h-1z M129,0h2v100h-2z M132,0h2v100h-2z M136,0h2v100h-2z M139,0h2v100h-2z M143,0h3v100h-3z M147,0h1v100h-1z M151,0h2v100h-2z M154,0h2v100h-2z M159,0h3v100h-3z M163,0h1v100h-1z M165,0h2v100h-2z" fill="#000000"/>
      </svg>
*/

You can find more info about the supported barcodes in the JsBarcode README.

Properties

Property Description
value What the barcode stands for (required).
format Which barcode type to use (default: CODE128).
width Width of a single bar (default: 2)
height Height of the barcode (default: 100)
text Override text that is displayed.
lineColor Color of the bars and text (default: #000000)
background Background color of the barcode (default: #ffffff)
onError Handler for invalid barcode of selected format

版本与发布记录

@adrianso/react-native-barcode-builder 共发布 8 个版本,首次发布于 2020/02/17;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.13latest2024/12/201.9 年前
1.0.13-beta.1beta2024/12/201.9 年前
1.0.122023/06/283 年前
1.0.112022/10/044 年前
1.0.102022/10/044 年前
1.0.92020/04/136 年前

关于 @adrianso/react-native-barcode-builder 的常见问题

@adrianso/react-native-barcode-builder 是什么?

React Native component to generate barcodes.

如何安装 @adrianso/react-native-barcode-builder?

在项目目录运行 npm install @adrianso/react-native-barcode-builder,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=16.8.1)、react-native(>=0.60.0 <1.0.x)、react-native-svg(>= 13.2.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@adrianso/react-native-barcode-builder 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@adrianso/react-native-barcode-builder 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@adrianso/react-native-barcode-builder 可以商用吗?

@adrianso/react-native-barcode-builder 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@adrianso/react-native-barcode-builder 的下载量有多少?

根据 npm 官方下载统计,@adrianso/react-native-barcode-builder 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,927 次,日均约 98 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@adrianso/react-native-barcode-builder 还在维护吗?

最新版本 1.0.13 发布于 2024/12/20(1.9 年前);至今共发布 8 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/02/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。