为什么这会给我一个TypeError: Cannot read property 'set' of undefined
?
Template.something.onCreated(function() {
this.templateDictionary = new ReactiveDict();
});
Template.something.onRendered(function() {
Template.templateDictionary.set( 'showExtraFields', true );
});
Template.something.helpers({
anything: function() {
var result = Template.instance().templateDictionary.get( 'showExtraFields' );
console.log(result);
}
});
答案 0 :(得分:0)
您的onRendered
功能需要修复:
Template.something.onRendered(function() {
Template.instance().templateDictionary.set( 'showExtraFields', true );
});