javascript - How to override default functionality in Ember-addons - Stack Overflow

In the ember-cli documentation it describes bridging the addon within your host application by overridi

In the ember-cli documentation it describes bridging the addon within your host application by overriding the app/ponent/[addon-name.js] yourself. However, the documentation doesn't explicitly state how to do this.

With trial and error I've noticed that by creating a ponent file in your [host app]/app/ponent/[name of addon.js] and simply copy/paste the addon code into there provides a venue to customize the addon. However, this is a terrible approach, I would imagine that I could simply override the functions in question...and in some cases call this.super().functionName in order to keep the over-rides simple and trim.

However, I can't get this to work. Any ideas?

In the ember-cli documentation it describes bridging the addon within your host application by overriding the app/ponent/[addon-name.js] yourself. However, the documentation doesn't explicitly state how to do this.

With trial and error I've noticed that by creating a ponent file in your [host app]/app/ponent/[name of addon.js] and simply copy/paste the addon code into there provides a venue to customize the addon. However, this is a terrible approach, I would imagine that I could simply override the functions in question...and in some cases call this.super().functionName in order to keep the over-rides simple and trim.

However, I can't get this to work. Any ideas?

Share Improve this question asked Apr 14, 2015 at 18:34 samsam 7631 gold badge7 silver badges15 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

Extensibility is why addons have both the addon/ and app/ trees. In the app tree for a ponent, the ponent should just be an import and export, for example:

import XSelect from 'emberx-select/ponents/x-select';
export default XSelect;

Source: https://github./thefrontside/emberx-select/blob/master/app/ponents/x-select.js

In this kind of case you want to create the ponent in [host app]/app/ponent/[name-of-addons-ponent.js] then in that ponent do:

import XSelect from 'emberx-select/ponents/x-select';

export default XSelect.extend({
  //any overrides
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744996427a4605219.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信