使用Scan Kit(统一扫码服务),通过文本生成生成码

使用Scan Kit(统一扫码服务),通过文本生成生成码

HarmonyOS
2024-08-07 09:17:11
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
噜啦噜啦嘞噜啦嘞
// 通过文本生成生成码 Promise方式
      Button('生成码').genButton()
        .onClick(() => {
          this.pixelMap = undefined;
          let content = this.mContext;
          let options: generateBarcode.CreateOptions = {
            scanType: this.mScanType,
            width: Number(this.mWidth),
            height: Number(this.mHeight),
            margin: Number(this.mMargin),
            level: this.mLevel,
            backgroundColor: this.mBackgroundColor,
            pixelMapColor: this.mPixelMapColor,
          }
          try {
            generateBarcode.createBarcode(content, options).then((result: image.PixelMap) => {
              this.pixelMap = result;
            }).catch((error: BusinessError) => {
              hilog.error(0x0001, TAG,
                `Failed to get pixelMap by promise with options. Code: ${error.code}, message: ${error.message}`);
            })
          } catch (error) {
            showError(error);
            hilog.error(0x0001, TAG, `Failed to createBarCode. Code: ${error.code}, message: ${error.message}`);
          }
        })
分享
微博
QQ
微信
回复
2024-08-07 11:24:17
相关问题
Scan Kit无法识别多个
1511浏览 • 1回复 待解决
相册识别多失败
1537浏览 • 1回复 待解决
AI生成能力中文字符乱码
9182浏览 • 1回复 待解决
ArkTs怎么实现一扫功能?
4165浏览 • 1回复 待解决
JS如何实现手机功能?
2650浏览 • 1回复 待解决
HarmonyOS 需要实现音效播放问题
124浏览 • 1回复 待解决
openHarmony-Api8项目,如何生成二维
669浏览 • 0回复 待解决
自定义界面预览画面出现拉伸
1627浏览 • 1回复 待解决
Arkts开发 api9 中怎么实现功能?
2664浏览 • 1回复 待解决