在#each中渲染视图 [英] Rendering a view inside #each
本文介绍了在#each中渲染视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每当我尝试在#each块中渲染视图时,我会得到一个PrecompilationError:编译器说:错误:每个视图不匹配视图
。
Whenever I try to render a view inside an #each block, I get a PrecompilationError saying: Compiler said: Error: each doesn't match view
.
示例:
{{#each posts}}
{{view App.MyPost}}
<div>Some HTML here</div>
{{/view}}
{{/each}}
在提交单个帖子之前,需要做一些事情,所以我的猜测是,我需要一个自定义视图(App.MyPost)来实现'willInsertElement'钩子。我做错了什么?
I need to do some stuff when before a single post is rendered, so my guess was that I need a custom view (App.MyPost) to implement the 'willInsertElement' hook. What am I doing wrong?
推荐答案
你错过了一个#
如果您想使用内联模板,则视图助手将执行一个#
If you want to use an inline template, the view helper takes a #
{{#each posts}}
{{#view App.MyPost}}
<div>Some HTML here</div>
{{/view}}
{{/each}}
so它基本上是:
{{view App.MyPost}}
或:
{{#view App.MyPost}}
<!-- template here -->
{{/view}}
这篇关于在#each中渲染视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文