【发布时间】:2015-12-14 13:42:28
【问题描述】:
在使用示例应用程序 here 配置 history 模块后,我遇到了这个问题。
我尝试在 react-router 文档Navigating Outside of Components 中遵循这种模式,并在
import createBrowserHistory from 'history/lib/createBrowserHistory';
export default createBrowserHistory();
用router配置
import React from 'react';
import {render} from 'react-dom';
import { Router, Route, Link, IndexRoute } from 'react-router';
import createHistory from 'history/lib/createBrowserHistory';
import history from './config/history';
import routes from './config/routes';
let el = document.getElementById('login');
render(<Router history={history}>{routes}</Router>, el);
尝试使用here
import history from '../config/history';
我正在使用webpack,您可以使用npm run webpack 构建它,然后使用python -m SimpleHTTPServer 8080 构建服务器文件。
之后,当我想去http://localhost:8080/public/login.html#/setup时,它给出了以下错误。
Warning: Location "/public/login.html#/setup?_k=rnwzln" did not match any routes
如果我删除了Login.js 中的history={history},它会完美运行
你能帮我解决这个问题吗?是不是 react-router 的 bug?
P.S.:我已经查看了这个 stackoverflow question,但它并没有解决我的问题。
【问题讨论】:
标签: react-router