IBest-Barcode
HarmonyOS NEXT 条形码组件
Github
IBest-Barcode由 安徽百得思维信息科技有限公司 开源,是一个轻量、简单易用的鸿蒙开源条形码组件, 支持CODE39、CODE93、CODE128、、EAN13、UPC、ITF、MSI、Pharmacode、Codabar等多种条码类型,同时支持状态管理V1和V2版本。
ohpm install @ibestservices/ibest-barcodeOpenHarmony ohpm 环境配置等更多内容,请参考如何安装 OpenHarmony ohpm 包
// V1项目使用
import { IBestBarCode } from '@ibestservices/ibest-barcode'
// V2项目使用
import { IBestBarCodeV2 } from '@ibestservices/ibest-barcode'
@Entry
@Component
struct Index {
build() {
List({space: 20}) {
IBestBarCode({
codeText: "FB19A1650-100S"
})
IBestBarCode({
codeType: "CODE39",
codeText: "code39"
})
IBestBarCode({
codeType: "EAN13",
codeText: "1234567890128"
})
IBestBarCode({
codeType: "EAN8",
codeText: "12345670"
})
IBestBarCode({
codeType: "UPC",
codeText: "123456789012"
})
IBestBarCode({
codeType: "ITF14",
codeText: "12345678901234"
})
IBestBarCode({
codeType: "MSI",
codeText: "200123456"
})
IBestBarCode({
codeType: "Codabar",
codeText: "A987654321012D"
})
IBestBarCode({
codeType: "CODE93",
codeText: "L000123456789"
})
IBestBarCode({
codeType: "Pharmacode",
codeText: "98765"
})
}
.width('100%')
.height('100%')
.padding({left: 20, right: 20})
}
}| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| codeType | 条形码类型 | IBestBarCodeType |
CODE39 |
| codeText | 条形码内容 | string |
"" |
| lineWidth | 条形码单个线条宽度 | number |
2 |
| lineColor | 条形码线条颜色 | string | number | CanvasGradient | CanvasPattern |
#000 |
| barHeight | 条形码高度(不包含文字) | number |
70 |
| showText | 是否显示文字 | boolean |
true |
| textColor | 条形码文字颜色 | string | number | CanvasGradient | CanvasPattern |
#000 |
| textFontSize | 条形码文字大小 | number |
12 |
| textAlign | 文字对齐方式 | left | center | right |
center |
| bgColor | 背景颜色 | string | number | CanvasGradient | CanvasPattern |
#fff |
| CODE128 | EAN | CODE39 | ITF | MSI | Pharmacode | Codabar | CODE93 |
|---|---|---|---|---|---|---|---|
| CODE128 | EAN13 | CODE39 | ITF | MSI | Pharmacode | Codabar | CODE93 |
| CODE128A | EAN8 | ITF14 | MSI10 | ||||
| CODE128B | EAN5 | MSI11 | |||||
| CODE128C | EAN2 | MSI1010 | |||||
| UPC | MSI1110 | ||||||
| UPCE |
注意:使用时请遵循条码类型规范,否则无法生成或报错。条形码只支持英文、数字、和一些常规符号,其它的会报错,非要生成中文或其它符号请自行转换为unicode码。
| 项目 | 描述 | |
|---|---|---|
| @ibestservices/ibest-ui | 一个轻量、简单易用、可定制主题、支持深色模式和浅色模式的鸿蒙开源UI组件库,基于状态管理v1版本。 | 地址 |
| @ibestservices/ibest-ui-v2 | 一个轻量、简单易用、可定制主题、支持深色模式和浅色模式的鸿蒙开源UI组件库,基于状态管理v2版本。 | 地址 |
| @ibestservices/ucharts | 一个类型丰富、高性能、可扩展、支持主题定制的图表库。 | 地址 |
| @ibestservices/area-data | 中国省市区数据,适用于鸿蒙 ArkUI 的 TextPicker 和 IBest-UI 的 IBestCascader 等组件。 | 地址 |
| @ibestservices/ibest-orm | 一个轻量、简单易用、全功能、支持实体关联、事务、自动迁移的鸿蒙开源 ORM 工具库。 | 地址 |
官方QQ群 953492584
在下述版本验证通过:
DevEco Studio 5.1.1 Release
Build #DS-233.14475.28.36.511823
构建版本:5.1.1.823, built on July 12, 2025
Runtime version: 17.0.12+1-b1087.25 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 15.5
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 12
Metal Rendering is ON
Registry:
idea.plugins.compatible.build=IC-233.14475.28
Non-Bundled Plugins:
com.harmonyos.cases (1.0.10-Alpha)
com.huawei.agc.ecomarket.component.plugin (233.14475.28)
com.alibabacloud.intellij.cosy (2.5.15)
本项目基于 MIT 协议,请自由地享受和参与开源。
感谢以下同学对IBest-Barcode做的贡献:



