繁体   English   中英

Meteor:将 onCreated 回调应用于所有模板

[英]Meteor: Applying the onCreated callback to all templates

我想在每个模板中的流星中的 onCreated 事件上运行一些代码。

我知道meteor 允许助手应用于所有模板:

Template.registerHelper("example", function() {
  // do something
});

但是是否可以注册一个适用于每个 onCreated 事件的函数?

您需要使用像template-extension这样的包:

meteor add aldeed:template-extension

那么你可以做这个

Template.onCreated(function () {
  // do something
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM