meteor:使用steeve生成qr代码:jquery-qrcode

时间:2016-05-08 12:47:25

标签: meteor qr-code

我使用 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'});
});`

1 个答案:

答案 0 :(得分:0)

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

引用的div

在你的html中你需要添加

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

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