frontend/src/App.js

36 lines
992 B
JavaScript

import ReactDOM from 'react-dom';
import React, { Component } from 'react';
import { HashRouter as Router, Route, Link } from "react-router-dom";
import "./App.css"
import "./assets/comm.css"
import {Redirect} from "react-router-dom";
import login from './pages/login/login';
import home from './pages/home/home';
import errpage from "./pages/errpage/errpage"
export default class App extends Component {
state = {
pathname:'',
};
componentWillMount(){
const pathname=window.location.href.lastIndexOf('\/');
const pathnamestr=window.location.href.substr(pathname);
this.setState({pathname:`${pathnamestr}`});
}
render() {
return (
<Router>
<Route path="/login" exact={true} component={login} />
<Route path="/home" component={home} />
<Route exact={true} path="/" render={
()=> (
<Redirect to="/login"/>)}>
</Route>
<Route component={errpage} />
</Router>
);
}
}