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>
考虑使用模板,这样你就可以这样做:
main.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/