我尝试使用 ReactiveVar。我不知道如何处理 ReactiveVar。这是我尝试过的代码。
Template.Home.helpers({
names: function(){
temp = Template.instance().name.get();
return temp;
}
});
Template.Home.onCreated(function () {
this.name = new ReactiveVar();
Meteor.call("getNames", function(error, result) {
if(error){
alert("Oops!!! Something went wrong!");
return;
} else {
this.name.set(result); // TypeError: Cannot call method 'set' of undefined
return;
}
});
});
我是否正确设置和获取 ReactiveVar?或如何设置和获取 ReactiveVar ?