我毫不费力地寻找使用Merame和Iframe的例子.(请注意,我必须使用iframe而不是DIV,因为最终会有内容).我试过了两个:
<body>
{{> hello}}
</body>
<template name="hello">
<h1>Hello World!</h1>
{{greeting}}
<input type="button" value="Click to see what you typed" />
<br>
<iframe id="compose" src={{> iframe-content}} height=600></iframe>
</template>
<template name="iframe-content">
<body>
<div contenteditable="true">
Edit me
</div>
</body>
</template>
Run Code Online (Sandbox Code Playgroud)
这会递归加载,不断创建子iframe.
我也试过了
<iframe id="compose" src="content.html" height=600></iframe>
Run Code Online (Sandbox Code Playgroud)
但Meteor将多个HTML文件混合在一起,这也会导致iframe失败.
到目前为止唯一有效的是SRCDOC而不是SRC,但是FF等多种浏览器并没有很好地支持它.
那么,在Meteor中使用iframe的诀窍是什么,最好是在模板中而不是严格地通过代码?