ReactJS将所选的const / component导入为所有(从{./comptest'导入{test1,test2}作为TST)

时间:2018-03-01 07:31:15

标签: reactjs

我在选择多个组件时遇到问题。

这项工作: import * as ROUTES from '../../constants/Routes';

这个没有,我只想从路由中选择多个组件 import {comp1, comp2, comp3} as ROUTES from '../../constants/Routes';

我会将它们传递给下拉组件并映射()下拉组件中传递的ROUTES

const DROP_DOWN_LINKS = ROUTES; <Dropdown links={DROP_DOWN_LINKS}/>

如何将这些称为import {comp1, comp2, comp3} as ROUTES from '../../constants/Routes';的作品?

1 个答案:

答案 0 :(得分:0)

import { Comp1, Comp2, Comp3 } from './mycomponent'

const arr = [Comp1, Comp2, Comp3]

arr.map(component => {
  // ... do whatever you want
})