API兼容性:
QRN:v8.0.10
iOS:80011358
Android:60001690
harmony:50000120
QBarcode 提供在客户端侧修改隐藏式条形码编码信息的能力。
QBarcode.showBarCode (param: object, successCallback: function, errorCallback: function)
param 为对象,字段如下:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
content |
string | 是 | 条形码内容,长度必须大于 0;需要可被 ASCII 编码;但是注意不要太长,因为会存在编码限制,和编码后识别成功率问题。目前建议长度限定在 25 个字符以内 |
successCallback(): void:展示成功回调errorCallback(error): void:展示失败回调error 字段如下:
| 字段 | 类型 | 说明 |
|---|---|---|
errorCode |
number | 失败错误码 |
errorMsg |
string | 失败信息(可能为空) |
import { QBarcode } from 'qunar-react-native';
var param = {
content: '11aa'
};
QBarcode.showBarCode(
param,
() => {
// success
},
(error) => {
error.errorCode;
error.errorMsg;
}
);
| errorCode | 含义 |
|---|---|
| 10 | viewController 不正确(为空 / 不是 UIViewController 子类) |
| 11 | content 为空(长度为 0) |
| 12 | ASCII 编码失败 |
| 13 | 生成条形码失败 |
| 14 | 找不到 window |