gpt4 book ai didi

javascript - EmberJS 何时使用 View ?

转载 作者:行者123 更新时间:2023-11-29 19:40:41 25 4
gpt4 key购买 nike

我是 EmberJS 的新用户,所以我想了解框架的 API 和核心组件。我难以理解的一个主要概念是何时使用 Ember.ViewEmber.Component。据我了解,Ember.Component 本质上是一种将您自己的标记/标签创建到模板中的方法,但是当我阅读 Ember 网站上的文章时,我仍然不明白什么时候会使用 View 与组件。

什么时候使用 Ember.ComponentEmber.View 有意义?我很想看到更多关于何时 Ember.View 至关重要且有意义的示例,但我就是不明白。很多时候我可以直接在我的 handlebars 模板中编写标记并且可以完全省略使用 Ember.Views.. 我想不出使用它的情况。

最佳答案

看看这个:Thoughts on Ember Views vs Components

In Ember, a view is always associated to a controller. A controller serves as a context for data provided to the View, as well as handling the view’s events.

Contrarily to Ember views, an Ember component is not connected to a related Ember Controller, since it is self contained, in which regards both the data and events that it handles. In this sense, components are easier to reuse in different places of the application, as well as in different applications.

关于javascript - EmberJS 何时使用 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23199628/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com