求助 锤子官网 的 React Router 大概要怎么写?

#1

求助 锤子官网 的 React Router 大概要怎么写?

http://锤子/jianguopro/#/overview
http://锤子/m1/#/overview
这样的。
不要跟我讲IDE 生成就好了。最好贴下干货。

#2

像是angular写的

#3

明明是angular4.0.1的主体架构不是 react

#4

两个页面的单叶把。

#5

我用的是react-router-dom,我是这样写的:

import React from 'react';
import {
  BrowserRouter as Router,
  Route,
  Redirect
} from 'react-router-dom';

import Home from './Home';
import Contact from './Contact';
import BookDetail from './BookDetail';
import BookList from './BookList';
import ReadingList from './ReadingList';
import AuthService from './widget/AuthService';
import Login from './Login';
import Admin from './Admin';

export const auth=new AuthService('...', 'xxxxx.auth0.com');

const requireAuth = auth.loggedIn();

const RoutingConfig = () => (
  <Router>
    <div>
      <Route exact path="/" component={Home}/>
      <Route path="/contact" component={Contact}/>
      <Route path="/books/:bookid.html" component={BookDetail}/>
      <Route path="/books/list/:type?/:key?/:page?" component={BookList}/>
      <Route path="/books/readings/:page?" component={ReadingList} />
      <Route path="/login" component={Login} auth={auth} />
      <Route exact path="/admin" render={() => (
        !requireAuth ? (<Redirect to="/login"/> ) : (<Admin/>)

      ) }/>
    </div>
  </Router>
);

export default RoutingConfig;
#6

你的模块不能接收到history mactch location之类的把。

#7

在我这个版本中我没有实现,因为我的应用中没有这个要求。