我毫不费力地寻找使用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的诀窍是什么,最好是在模板中而不是严格地通过代码?
你想要'public'文件夹.Meteor单独留下该文件夹中的内容,如下所述:http://docs.meteor.com/#/full/structuringyourapp
将'content.html'移动到项目/应用程序根目录下名为'public'的文件夹中,并在html中引用它:
<head>
<title>iframe</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
<h1>Hello World!</h1>
{{greeting}}
<input type="button" value="Click" />
<iframe src="hello.html"></iframe>
</template>
Run Code Online (Sandbox Code Playgroud)
为了清楚其他读者,Meteor对iframe没有任何问题.问题在于引用iframe的'content.html'文件的位置.
| 归档时间: |
|
| 查看次数: |
4558 次 |
| 最近记录: |