中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
使用Scan Kit(统一扫码服务),通过文本生成生成码
微信扫码分享
// 通过文本生成生成码 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}`); } })