我正在嘗試按照反應教程進行操作。我被卡在一個部分,我不斷收到一條路線不匹配錯誤。react router位置「// playerOne」與任何路徑不匹配
我的代碼有什麼問題,或者這種技術已經過時了嗎?這裏是我的框架版本:
"babel-preset-es2015": "^6.16.0",
"react": "^15.3.2",
"react-dom": "^15.3.2",
"react-router": "^2.8.1"
這裏是我的路由器代碼:
var React = require('react');
var ReactRouter = require('react-router');
var Router = ReactRouter.Router;
var Route = ReactRouter.Route;
var hashHistory = ReactRouter.hashHistory;
var IndexRoute = ReactRouter.IndexRoute;
var Main = require('../components/Main');
var Home = require('../components/Home');
var PromptContainer = require('../containers/PromptContainer');
var routes = (
<Router history={hashHistory}>
<Route path='/' component={Main}>
<IndexRoute component={Home} />
<Route path='/playerOne' component={PromptContainer} />
<Route path='/playerTwo/:playerOne' component={PromptContainer} />
</Route>
</Router>
);
module.exports = routes;
這裏是我的PromptContainer:
var React = require('react');
var PromptContainer = React.createClass({
render: function() {
return (
<div className="jumbotron col-sm-6 col-sm-offset-3 text-center">
<h1>SOME HEADER TEXT</h1>
<div className="col-sm-12">
<form>
<div className="form-group">
<input className="form-control"
placeholder="Github username"
type="text" />
</div>
<div className="form-group col-sm-4 col-sm-offset-4">
<button className="btn btn-block btn-success"
type="submit">
Continue
</button>
</div>
</form>
</div>
</div>
);
}
});
module.exports = PromptContainer;
爲什麼2濺在你的問題? 'react router Location「// playerOne」does not match any routes' – KOTIOS
@MyMasterPeice這是我在瀏覽到此URL時得到的錯誤 http:// localhost:8080 /#/?_k = xxxx/playerOne – Corbee
確保你正確地引用'PromptContainer'? – KOTIOS