代码:
效果:
补充:
无论是定义了哪个路由,都会默认带一个_k的query,不知道为啥,求解?
import { Router, Route, IndexRoute, hashHistory } from 'react-router';
import { createHashHistory } from 'history';
var routerHistory = require('react-router').useRouterHistory; //去掉?_k=****
const appHistory = routerHistory(createHashHistory)({ queryKey: false }) ;
import App from './app';
import Editor from './editor';
import Previewer from './previewer';
import Sbrt from './sbrt';
import React from 'react';
import ReactDOM from 'react-dom';
/*hashHistory 有sbrt?_k=pm2dkp*/
const router = <Router history={appHistory}>
<Route path='/' component={App}>
<IndexRoute component={Editor} />
<Route path='editor' component={Editor} />
<Route path='previewer' component={Previewer} />
<Route path='sbrt' component={Sbrt} />
</Route>
</Router>;
ReactDOM.render(
router,
document.getElementById('content')
);
4 回答1.6k 阅读
2 回答1.1k 阅读✓ 已解决
2 回答2.6k 阅读
1 回答952 阅读✓ 已解决
1 回答682 阅读✓ 已解决
2 回答844 阅读✓ 已解决
2 回答1k 阅读
官方文档对这个有说明:
https://github.com/reactjs/react-router/...