javascript - 如何维护加载到 meteor 应用程序中的 HTML head/body block 的顺序?

标签 javascript meteor

来自http://docs.meteor.com

Meteor scans all the HTML files in your directory for three top-level elements: <head>, <body>, and <template>. The head and body sections are separately concatenated into a single head and body, which are transmitted to the client on initial page load.

非常好的功能,但我现在遇到了以下问题。

如何维护加载到 meteor 应用程序中的 HTML 头/正文 block 的顺序?

最佳答案

您当前正在做的事情很可能是这样的:

file1.html

<body>
    <!-- some stuff -->
</body>

file2.html

<body>
    <!-- some other stuff -->
</body>

考虑使用模板,这样你就可以这样做:

ma​​in.html

<body>
    {{> template1}}
    {{> template2}}
</body>

file1.html

<template name="template1">
    <!-- some stuff -->
</template>

file2.html

<template name="template2">
    <!-- some other stuff -->
</template>

您应该做什么:确保您的模板可以帮助您定义 HTML 流程;其他一切都可以用CSS positioning来完成,甚至 changing flow for things with a defined height or width .

你不应该做什么:按字母顺序命名文件,以便 Meteor 按顺序排列它们。使用 jQuery 对正文的内容进行排序,使用 .bind.on 并列出插入 DOM 节点的事件;当插入一个时,您将其移动到正确的位置。 这些都是坏习惯

关于javascript - 如何维护加载到 meteor 应用程序中的 HTML head/body block 的顺序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10571688/

相关文章:

javascript - "overflow-x: scroll"的百分比宽度 <div> 不起作用,即使在跨度内

javascript - 使用 Meteor 返回 MongoDB 中具有单个字符串值的数组

node.js - 范围错误 : Invalid array buffer length Error - Reaction Commerce Installation

meteor - 发布用户所在组的项目(规划角色和发布)

javascript 查找值是否不在数组中

javascript - Angularjs 数据存储最佳实践

javascript - 获取客户的日期格式名称

javascript - Jquery Mobile 按钮在第二次单击时不起作用

javascript - Meteor 中用于搜索和显示文档的标准模式

javascript - 从客户端更新 Meteor.users