React router意外的令牌

时间:2016-07-25 15:26:22

标签: reactjs react-router

我正在尝试为我的应用程序实现React路由器,看起来像这样

import React from "react";
import ReactDOM from "react-dom";
import { Router, Route, Link, browserHistory } from 'react-router';

import Login from './Login';
import SignIn from './SignIn';
import Chat from './Chat';

require("../../view/style.less");

const app = document.getElementById('app');

ReactDOM.render((
   <Router history={browserHistory}>
      <Route path="/" component ={Login} />
      <Route path="signin" component ={SignIn} />
      <Route path="chat" component ={Chat}  />
   </Router>
), app);

当我查看我的控制台时,它会给出错误Unexpected token

这是控制台错误输出。有什么问题?

 ReactDOM.render((
> 14 |    <Router history={browserHistory}>
     |    ^
  15 |       <Route path="/" component ={Login} />
  16 |       <Route path="signin" component ={SignIn} />
  17 |       <Route path="chat" component ={Chat}  />

1 个答案:

答案 0 :(得分:2)

只是一个括号的故事。

ReactDOM.render(
   <Router history={browserHistory}>
      <Route path="/" component ={Login} />
      <Route path="signin" component ={SignIn} />
      <Route path="chat" component ={Chat}  />
   </Router>, app);