是否可以有条件地扩展 Ember 类?像这样的东西:
A.reopen({
if (condition) {
init: function() {
this.super();
// some functionality
}.on('didInsertElement');
}
})
目前我有这样的模式:
A.reopen({
init: function() {
this.super();
if (condition) {
// some stuff
}
}.on('didInsertElement'),
cleanup: function() {
if (condition) {
// some stuff
}
}.on('willDestroyElement')
})
我猜想如果我可以扩展 A 类,我可以像这样简化我的模式:
A.reopen({
if (condition) {
init: function() {
this.super();
// some functionality
}.on('didInsertElement'),
clear_up: function() {
// some stuff
}.on('willDestroyElement')
}
})
在插件中为话语制作的所有类扩展