Template.hello.loggedin = function() { return something }
对比
Template.hello.helpers({
'loggedin': function () { return something }
})
前者有效(Template.hello.loggedin 在控制台中打印出函数,添加括号返回某些东西),后者无效(未定义)。
我以为这些是等价的??
最佳答案
除了您发现的情况外,它们是等价的。 github 上有一个关于此的未解决问题:https://github.com/meteor/meteor/issues/886 .
如果你想调用 Template.hello.loggedin()
使用前者。
关于javascript - meteor.js 模板助手作为变量与键+值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20362393/