我的反应路由器工作正常但是当我添加params路由器然后显示一些错误,如Uncaught SyntaxError:意外的令牌<
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, Link, browserHistory, IndexRoute } from 'react-router';
import App from './containers/App';
import Greetings from './containers/Greetings';
import SignupPage from './containers/signup/SignupPage';
import Screen from './containers/signup/Screen1';
import LoginPage from './containers/login/LoginPage';
export default (
<Router history = {browserHistory}>
<Route path = "/" component = {App}>
<IndexRoute component = {SignupPage} />
<Route path = "signup" component = {SignupPage} />
<Route path = "login" component = {LoginPage} />
<Route path = "/screen/:id" component = {Screen} />
</Route>
</Router>
)
&#13;
答案 0 :(得分:0)
路由器的格式可能已关闭 - 在道具之间添加空格可能会导致语法错误。注意我还导出了一个名为router的变量,因为这是显式导出的一种更好的做法。尝试重写路由器,如下所示:
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, Link, browserHistory, IndexRoute } from 'react-router';
import App from './containers/App';
import Greetings from './containers/Greetings';
import SignupPage from './containers/signup/SignupPage';
import Screen from './containers/signup/Screen1';
import LoginPage from './containers/login/LoginPage';
export default router = (
<Router history={browserHistory}>
<Route path="/" component={App}>
<IndexRoute component = {SignupPage} />
<Route path="signup" component={SignupPage} />
<Route path="login" component={LoginPage} />
<Route path="/screen/:id" component={Screen} />
</Route>
</Router>
)
&#13;