1
我正在使用meteor reactive-var包。我怎樣才能獲得在模板的js文件中定義的匿名函數中的反應變量? viewer.js:在匿名函數中獲取ReactiveVar
Template.viewer.helpers({
counter: function() {
return Template.instance().counter.get();
}
});
Template.viewer.onCreated(function() {
this.counter = new ReactiveVar(0);
});
Template.viewer.onRendered(function(e){
viewerRendered();
});
function getCounter() {
// !!Return reactive counter variable
}
function viewerRendered() {
var counter = getCounter();
$(document).trigger("ViewerCreated",counter);
}
謝謝。