gpt4 book ai didi

ember.js - Ember.Application.create 与 Ember.Application.extend

转载 作者:行者123 更新时间:2023-12-04 21:14:06 24 4
gpt4 key购买 nike

我注意到在 app.js由 Ember CLI (v0.1.12) 生成的文件,他们使用:

var App = Ember.Application.extend({...})

但在 introduction guide ,他们正在使用:
window.App = Ember.Application.create({...});

创建 Ember 应用程序的这两种(创建与扩展)方式之间的结果有什么不同吗?

最佳答案

如 Ember 文档中所述 extend Creates a new subclass,尽管
create Creates an instance of a class .

主要区别在于使用 extend

you can override methods but still access the implementation of your parent class by calling the special _super() method



但是 create负担不起那种能力。

链接的文档有很好的代码示例,专门针对您的问题。



The create() on line #17 creates an instance of the App.Soldier class. The extend() on line #8 creates a subclass of App.Person. Any instance of the App.Person class will not have the march() method.



以及处理该报价的代码。

关于ember.js - Ember.Application.create 与 Ember.Application.extend,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28438907/

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