3

我试图让这个示例使用最新的 ember 版本,但我遇到了几个错误。我无法更正代码,因为我缺乏一些基本的了解。该示例view以两种不同的方式使用帮助程序:

<script type="text/x-handlebars">
    {{#view Ember.View contentBinding="App.myModel"}}
            {{#view App.PreviewUploadImage name="logo_image" contentBinding="content"}}
                {{view fileField}}
                {{view previewImageView width="200" height="100" srcBinding="content.myModel_src"}}
            {{/view}}
    {{/view}}
</script>

视图助手的两种用法(view和)有什么区别?#view而且,作为一个更基本的问题,带前缀和不带前缀的助手有什么区别#

4

1 回答 1

6

The main difference is that {{view}} is used when you don't wrap anything inside the view helper and {{#view}} when you have something to wrap, like in your example, also when using {{#view}} a closing tag {{/view}} has to follow. The latter is true for all block helper.

Most common example of a block helper is:

{{#link-to}}My link{{/link-to}}

And the most common non-block helper:

{{input type="text" value="foo"}}

Hope it helps.

于 2013-09-21T18:36:41.133 回答