Meteor:根据Session等于什么显示不同的数据
Meteor: display different data based on what Session equals
有没有办法在 Meteor 中使用与此类似的东西
{{#if $.Session.equals 'sessionName' value1}}
<p> value1 </p>
{{/if}}
{{#if $.Session.equals 'sessionName' value2}}
<p> value2 </p>
{{/if}}
{{#if $.Session.equals 'sessionName' value3}}
<p> value3 </p>
{{/if}}
我正在尝试使用助手,但无法正常工作:
{{#if 'helperName' value1}}
<p> value1 </p>
{{/if}}
{{#if 'helperName' value2}}
<p> value2 </p>
{{/if}}
{{#if 'helperName' value3}}
<p> value3 </p>
{{/if}}
Template.name.helpers({
helperName: function (item) {
return Session.equals('currentItem', item);
},
});
onBeforeAction: function() {
Session.set('currentLastItem', 'value1');
this.next();
}
And I get error statement that there is no such function as helperName
这个原理是一样的,只是用来根据当前路由渲染不同的数据 - Meteor: Change the class of link on click
这将允许您使用上面使用的语法:
有没有办法在 Meteor 中使用与此类似的东西
{{#if $.Session.equals 'sessionName' value1}}
<p> value1 </p>
{{/if}}
{{#if $.Session.equals 'sessionName' value2}}
<p> value2 </p>
{{/if}}
{{#if $.Session.equals 'sessionName' value3}}
<p> value3 </p>
{{/if}}
我正在尝试使用助手,但无法正常工作:
{{#if 'helperName' value1}}
<p> value1 </p>
{{/if}}
{{#if 'helperName' value2}}
<p> value2 </p>
{{/if}}
{{#if 'helperName' value3}}
<p> value3 </p>
{{/if}}
Template.name.helpers({
helperName: function (item) {
return Session.equals('currentItem', item);
},
});
onBeforeAction: function() {
Session.set('currentLastItem', 'value1');
this.next();
}
And I get error statement that there is no such function as helperName
这个原理是一样的,只是用来根据当前路由渲染不同的数据 - Meteor: Change the class of link on click
这将允许您使用上面使用的语法: