what is the Template.templateName.rendered= function(){} in

what is the Template.templateName.rendered= function(){} in Meteor js

本文关键字:in function the is Template templateName rendered what      更新时间:2023-09-26

这是我的第一个流星项目,我试图了解流星本身在同一时间。现在我遇到了以下语法:

Template.editor.rendered = function() {
    // some stuff here 
}

虽然我已经在网上看了,但我找不到这种函数是什么。我的意思是,我想知道我应该在这个函数里面放些什么,这个函数什么时候会被调用?例如,如果我有一个像localhost:3000/test这样的url,当我在浏览器中输入这个url时,这个动作会调用Template.test.rendered= function()吗?

rendered回调类似于jQuery中的ready()或香草Javascript中的DOMContentLoaded

从文档

注册一个函数,当这个模板的实例被插入到DOM中时调用。

使用此方法添加的回调函数在模板的实例中调用一次。myTemplate第一次呈现为DOM节点并放入文档中。