gpt4 book ai didi

javascript - 如何在 Meteor 中显示 "static"html 页面?

转载 作者:行者123 更新时间:2023-12-03 07:27:17 25 4
gpt4 key购买 nike

我想在 Meteor 应用程序上单击页面的组件时显示“静态”html 页面。该页面的唯一功能是显示信息,我根本不希望用户与其交互。所需的功能是我的一个表单中有一个“单击查看示例”标签(实际上是一个链接),它将显示带有预先填充信息的同一表单的“模拟快照”,作为此类示例每个字段的预期信息。

当然,这个应用程序使用模板(包括导航栏、页脚等),因此在单击关联的 Template.XYZ.events 上的链接后,我正在使用 window.open 显示该“模拟页面”(最好作为新窗口而不是新选项卡)。

问题是我忘记了 Meteor 是一个固执己见的工具,有它自己的方式 structuring the app and loading files这样,“静态”页面在新窗口中显示时,也具有导航栏和页脚(我相信这会让一些尝试在新窗口中遵循流程的用户感到困惑)。

我尝试使用模板来显示此静态页面,在这种情况下,我获得了导航栏和页脚以及所有页面通用的其他组件。我尝试使用“原始”html 页面,但由于 Meteor 加载文件的方式,我只是加载此 html 页面并在各处显示。我想将其移动到“私有(private)”目录,但随后我不确定如何访问它(我使用过 Assests ,但要从服务器端访问内容)。

如何在 Meteor 应用上通过 window.open 显示此“断开连接”页面?

我知道 Meteor 的目标是构建令人惊叹的“单页”网站,因此我猜测这种行为可能有点违反拥抱生态系统原则。我不知道我想要的东西在这个平台上是否可能实现,如果可以的话,如何实现。

最佳答案

我发现您正在使用 Iron Router。它允许您为不同的路线定义不同的布局(它可能解决这里的问题)。这是一个演示如何执行此操作的小示例。

HTML

<template name="hello">
<button class="sayHello">Click Me</button>
{{> sayGoodbye}}
</template>

<template name="sayGoodbye">
<button class="goodbye">
Goodbye
</button>
</template>

<template name="ApplicationLayout">

<div class="container-fluid">

<div class="mainarea">
This is a first layout.<br>
{{>yield "main"}}
</div>

</div><!-- / container -->

</template>

<template name="homeLayout">

<div class="container-fluid">

<div class="mainarea">
This is a second layout.<br>
{{>yield "main"}}
</div>

</div><!-- / container -->


</template>

Router.js file in the lib folder

Router.configure({
layoutTemplate: 'ApplicationLayout',
layoutTemplate: 'homeLayout',
});


Router.route('/', function(){
this.layout('ApplicationLayout');
this.render("hello", {to: "main"});
});

Router.route('/different', function(){
this.layout('homeLayout');
this.render("hello", {to: "main"});
});

所以,基本上你可以为静态页面定义一个根。然后,将其布局编码为布局模板并使用 this.layout() 函数来显示它。

关于javascript - 如何在 Meteor 中显示 "static"html 页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35948904/

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