我想在我的應用程序中實現React-Router。我已經在index.js中初始化了路由器,它工作正常。但它不會更改瀏覽器中的URL並在控制檯中引發此錯誤。反應路線中的URL不會改變
警告:[react-router]`Router`不再默認history歷史記錄。請改用`hashHistory`單例。Index.js
import 'core-js/fn/object/assign';
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, browserHistory,IndexRoute } from 'react-router';
// Custom Components
import App from './components/Main';
import Dashboard from './components/containers/Dashboard';
import Settings from './components/containers/Settings';
import Workspace from './components/containers/Workspace';
import Main from './components/Main';
ReactDOM.render((
<Router histrory={browserHistory}>
<Route path="/" component={Main}>
<IndexRoute component={Dashboard}></IndexRoute>
<Route path="/workspace" component={Workspace}></Route>
<Route path="/dashboard" component={Dashboard}></Route>
<Route path="/settings" component={Settings}></Route>
</Route>
</Router>
), document.getElementById('app'));
Main.js
require('normalize.css/normalize.css');
require('styles/App.scss');
//Import Custom Components
import React from 'react';
import { Router, Route,Link, browserHistory } from 'react-router';
import Sidenav from './containers/Sidenav';
import Page from './Page';
class AppComponent extends React.Component {
render() {
return (
<div>
<Sidenav />
<div className="page-wrap">
{this.props.children}
</div>
</div>
);
}
}
AppComponent.defaultProps = {
};
export default AppComponent;
路線是工作的罰款和組件是越來越正確呈現。請建議將其與網址綁定。
預先感謝您。 :d
拼寫歷史是錯誤的?這是你的代碼中的拼寫錯誤嗎? –