【问题标题】:NativeScript-vue Barcode creationNativeScript-vue 条码创建
【发布时间】:2020-10-15 10:46:41
【问题描述】:

您好,我想问一下是否有在 nativescript-vue 中创建条形码的方法,有很多创建条形码的 vue js 示例,但我没有能力翻译或转换代码。有没有人可以给我一个在 nativescript-vue 上创建条形码的例子?谢谢。

【问题讨论】:

    标签: nativescript-vue


    【解决方案1】:

    您可以使用nativescript-qr-generator & nativescript-base-64-manager

    base-64 仅当您想将 QR 码转换为 base-64 时。

    将其导入您的模板:

    import { QrGenerator } from "nativescript-qr-generator";
    import { Base64Manager } from "nativescript-base-64-manager";
    

    你需要一个数据属性generatedQR: null,然后你需要一个方法来生成二维码。所以生成了二维码,然后你的代码值被转换为base64值。您还可以将任何数据附加到结果中,例如 url:new QrGenerator().generate("url/" + _Base64Manager.btoa(this.code)

     generateQR() {
          const _Base64Manager = new Base64Manager();
          const result = new QrGenerator().generate( _Base64Manager.btoa(this.code),
            {
              color: "#your_color",
              backgroundColor: "#your_color"
            }
          );
          this.generatedQR = new ImageSource(result);
        }
    

    在模板中,您将拥有像图像一样的二维码:

    <Image :src="generatedQR" row="4" imageFit="aspectFill"/>
    

    【讨论】:

    • 抱歉回复晚了,谢谢你的回答,但这会生成非二维码吗?我需要条码一个。
    猜你喜欢
    • 2020-04-03
    • 2019-08-07
    • 2021-07-24
    • 1970-01-01
    • 2019-01-17
    • 2022-12-13
    • 2019-10-15
    • 2019-09-04
    • 2019-03-06
    相关资源
    最近更新 更多