我在我的ember-cli項目中使用了ember-notify ember-notify。Ember-notify給出錯誤無法讀取未定義的屬性「服務」
import {
Component,
inject
} from 'ember';
export default Component.extend({
notify: inject.service('notify'),
actions: {
sayHello() {
this.get('notify').info('Hello there!');
}
}
});
我剛剛從文檔中複製了相同的示例代碼。但我得到錯誤「無法讀取屬性」服務「的線路notify: inject.service('notify'),
未定義'我已經安裝了這個插件,並做了一個npm安裝。
您是否在安裝插件後重新啓動服務器? –
我不知道'inject'是否可以直接導入。你可以嘗試明確地解決這個問題:'從'ember'導入Ember;'並使用'Ember.inject.service('notify')'。 – spectras