index.js
954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import 'core-js/es6/map';
import 'core-js/es6/set';
import 'core-js/es6/promise'
import 'core-js/es6/object'
import 'whatwg-fetch'
import React from 'react';
import {render} from 'react-dom';
import config from '../../config';
import {BrowserRouter, Route, Switch} from 'react-router-dom';
import router from './router';
const routers = () => {
let arr = [];
Object.keys(router).forEach((key,index)=> {
if(index === 0){
arr.push(<Route key={index} exact path={config.routerPath[config.currentApp] + '/'+key+'.html'} component={router[key]}/>)
}else{
arr.push(<Route key={index} path={config.routerPath[config.currentApp] + '/'+key+'.html'} component={ router[key]}/>)
}
})
return arr;
}
const SliderComponent = () => (
<Switch>
{routers()}
</Switch>
);
render(
<BrowserRouter>
<SliderComponent/>
</BrowserRouter>,
document.querySelector("#root")
);