簡體   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