使用 steeve:jquery-qrcode 生成二维码
Generating QR codes using steeve:jquery-qrcode
我正在做一个流星项目,我想为每个用户分配一个二维码。
我做了一些研究,发现 steeve:jquery-qrcode
(在此处找到:https://atmospherejs.com/steeve/jquery-qrcode)是一种执行此操作的方法。
很遗憾,我找不到有关如何使用此包的任何信息。我错过了什么吗?因为ReadMe文件中没有太多介绍这个包的使用。
不然有没有更好的包可以用来在流星项目中生成二维码?
这个包只是导入原始的jquery-二维码。
您可以在此处找到说明:https://github.com/jeromeetienne/jquery-qrcode.
// basic usage:
$('selector').qrcode({text: 'some string'});
如果您必须在不使用反应式数据源的情况下生成二维码,您可以在 Template.YourTemplate.onRendered()
上调用代码
Template.YourTemplate.onRendered(function () {
$('selector').qrcode({text: 'some string'});
});
但如果您必须动态更改二维码,您可以这样做:
<template name="hello">
<div class="testqrcode" data-qrcode="{{someReactiveData}}"></div>
</template>
if (Meteor.isClient) {
var counter = new ReactiveVar(0);
Meteor.setInterval(function () {
counter.set(counter.get() + 10);
}, 300);
Template.hello.helpers({
someReactiveData: function () {
Tracker.afterFlush(function () {
$('.testqrcode').each(function (i, e) {
$(e)
.empty()
.qrcode({text: $(e).attr('data-qrcode')});
});
});
return Meteor.absoluteUrl() + counter.get();
}
});
}
我正在做一个流星项目,我想为每个用户分配一个二维码。
我做了一些研究,发现 steeve:jquery-qrcode
(在此处找到:https://atmospherejs.com/steeve/jquery-qrcode)是一种执行此操作的方法。
很遗憾,我找不到有关如何使用此包的任何信息。我错过了什么吗?因为ReadMe文件中没有太多介绍这个包的使用。
不然有没有更好的包可以用来在流星项目中生成二维码?
这个包只是导入原始的jquery-二维码。 您可以在此处找到说明:https://github.com/jeromeetienne/jquery-qrcode.
// basic usage:
$('selector').qrcode({text: 'some string'});
如果您必须在不使用反应式数据源的情况下生成二维码,您可以在 Template.YourTemplate.onRendered()
上调用代码Template.YourTemplate.onRendered(function () {
$('selector').qrcode({text: 'some string'});
});
但如果您必须动态更改二维码,您可以这样做:
<template name="hello">
<div class="testqrcode" data-qrcode="{{someReactiveData}}"></div>
</template>
if (Meteor.isClient) {
var counter = new ReactiveVar(0);
Meteor.setInterval(function () {
counter.set(counter.get() + 10);
}, 300);
Template.hello.helpers({
someReactiveData: function () {
Tracker.afterFlush(function () {
$('.testqrcode').each(function (i, e) {
$(e)
.empty()
.qrcode({text: $(e).attr('data-qrcode')});
});
});
return Meteor.absoluteUrl() + counter.get();
}
});
}