【问题标题】:meteor : generate qr code using steeve:jquery-qrcode流星:使用 steeve:jquery-qrcode 生成二​​维码
【发布时间】:2016-05-18 12:35:03
【问题描述】:

我已经使用 steeve:jquery-qrcode 包创建了 qrcode,但现在我无法根据 _id 集合显示 qrcode 图像(文本)。我想要 _id 数据作为 qrcode 图像,扫描结果是 _id 数据。请有人帮助我。

这是我的代码: //html

`<template name="profile">
<div class="container-fluid">
Username: {{kategori}}<br />
{{#if profil}}
Profile name: {{kategori}}
{{/if}}
  <div class="qrblock" id="qrblock"  src="/{{. }}"> </div>

<a id="downloadImgLink" onclick="$('#downloadImgLink').attr('href', $('#qrblock canvas')[0].toDataURL());" download="MyImage.png" href="#" target="_blank">Download Drawing</a>
</div>
</template>`

//js

`Template.profile.helpers({
profil: function(){
return Profil.find({});
}
});
Template.profile.onRendered(function (event) {
 this. $('.container').qrcode({itemSelector: '.qrblock'});
});`

【问题讨论】:

    标签: meteor qr-code


    【解决方案1】:

    您缺少使用 jquery 选择器 $('.container').qrcode({itemSelector: '.qrblock'}); 引用的 div

    在你的html中你需要添加

    <div class="container"></div>
    

    同样在 .qrcode() 中,您应该使用“文本”在 qr 代码阅读器端写入您想要接收的内容,例如.qrcode({ text: "http://stackoverflow.com"})

    【讨论】:

    • 但是我希望用户点击数据时自动生成 qrcode。你能明白我的意思吗?
    • 那么同样适用,但把 $('.container').qrcode({ text: "stackoverflow.com" });在 onClink 事件中并将“text”的值作为 js 变量传递,例如{文本:textVar}
    猜你喜欢
    • 1970-01-01
    • 2013-07-05
    • 2014-06-21
    • 1970-01-01
    • 2022-12-16
    • 1970-01-01
    • 2018-09-03
    • 2014-08-14
    • 1970-01-01
    相关资源
    最近更新 更多