JavaScript(ReactJS),从
我有这个组件(代码的一半): 应用程序: 分层分离机:JavaScript(ReactJS),从,javascript,reactjs,Javascript,Reactjs,我有这个组件(代码的一半): 应用程序: 分层分离机: ... import IconLayers, {stateIcon} from "../layers/IconLayers"; ... export default class LayerActivator extends Component { IconLayers: export const stateIcon = { Marker: 1, Heatmap: 2, Cluster: 3 } class IconLayer
...
import IconLayers, {stateIcon} from "../layers/IconLayers";
...
export default class LayerActivator extends Component {
IconLayers:
export const stateIcon = {
Marker: 1,
Heatmap: 2,
Cluster: 3
}
class IconLayers extends Component {
...
}
export default IconLayers;
我想要的是在“App”中导入一行LayerActivator
和{statecon}
,因为
`stateIcon` is defined inside `IconLayers`,
and `IconLayers` is imported on `LayerActivator`
这是可能的?您可以在
LayerActivator
文件中重新导出状态图标
,但老实说,您应该尽可能将所有内容分开,以从树震动的最佳结果中获益……只需像现在这样用两行代码导入它们。
`stateIcon` is defined inside `IconLayers`,
and `IconLayers` is imported on `LayerActivator`