gpt4 book ai didi

javascript - 在 Meteor JS 中动态加载多个模板?

转载 作者:行者123 更新时间:2023-11-30 05:39:49 25 4
gpt4 key购买 nike

如何在 Meteor JS 中加载多个模板?我知道如何动态加载单个模板。但无法加载多个模板。请查看下面加载单个模板的代码并建议我如何加载多个模板?

JS 代码:

Meteor.startup(function () 
{
Session.set('currentTemplate', 'login');
});
Template.content.helpers
({
'renderTemplate': function()
{
if(Session.get('currentTemplate') == undefined)
{
Session.set('currentTemplate', 'login');
}
return new Handlebars.SafeString(Template[Session.get('currentTemplate')]({dataKey: '0'}));
}
})

最佳答案

将一个模板加载到另一个模板中:

<template name="oneTemplate">
{{> anotherTemplate}}
</template>

要根据 url 加载不同的模板,最好使用 Iron Router .

关于javascript - 在 Meteor JS 中动态加载多个模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21478328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com