How to import two classes by the same name in javascript/es6?

后端 未结 2 472
再見小時候
再見小時候 2020-12-03 04:37

I have these two import statements in file:

import Data from \'component/Data.js\';
import Data from \'actions/Data.js\';

Both files contai

2条回答
  •  生来不讨喜
    2020-12-03 04:51

    EDITED: As per RGraham answer, updating my answer:

    Can't you import it like this:

    import {Data as D1} from 'component/Data.js';
    import {Data as D2} from 'actions/Data.js';
    

    Then use it as you require:

    D1.{}
    D2.{}
    

    referenced from: https://github.com/lukehoban/es6features/blob/master/README.md/#user-content-modules

提交回复
热议问题