Is it possible to do multiple class imports with ES6/Babel?

前端 未结 4 474
借酒劲吻你
借酒劲吻你 2020-12-28 13:10

I\'m working on a react project (my first) and I\'ve recently restructured my folder structure to make a bit more sense.

To make my life easier, within my component

4条回答
  •  攒了一身酷
    2020-12-28 13:19

    I use export that looks something like this. In react it worked well

    export {default as PublicRoute} from './PublicRoute';
    export {default as PrivateRoute} from './PrivateRoute';
    

    Then, you can import like this wherever you need:

    import {PublicRoute, PrivateRoute} from './config/router';
    ...
    

提交回复
热议问题