0
我使用了很多類似的類,它們都使用相同的依賴關係,因此它們都以相同的ES2015導入語句列表開始。我想知道的是,使用繼承或什麼的,我可以這樣做,這只是在父母需要防止冗餘代碼?請注意,我爲每個文件使用1個類。在JavaScript ES2015擴展類中,我必須重新導入所有依賴項嗎?
import angular from 'angular;
import {subscribeReducer} from '../shared/helpers/reduce.helper';
import newhomeReducer from './newhome.reducer';
import {subscribeSaga} from '../shared/helpers/saga.helper';
import newhomeSagas from './newhome.saga';
class Newhome{...something...};
,然後第2類:
import angular from 'angular;
import {subscribeReducer} from '../shared/helpers/reduce.helper';
import currenthomeReducer from './newhome.reducer';
import {subscribeSaga} from '../shared/helpers/saga.helper';
import currenthomeSagas from './newhome.saga';
class Currenthome{...something...};
你只需要導入你引用的內容,所以如果你沒有引用某個東西,那麼你就不需要導入了。另外一個好的編輯器會讓你知道你沒有引用什麼,例如。我使用Atom.IO,eslint,如果我添加一個未被引用的導入,它會讓我知道。 – Keith