解析错误:意外的令牌,预期为“;

时间:2019-03-27 11:02:58

标签: reactjs parsing syntax-error

我在Reactjs学习中遇到很多我不理解的问题。我在App.js中遇到Line 5: Parsing error: Unexpected token, expected ";错误,我无法理解我做错了什么。请帮忙!

我也尝试过更改扩展名,但不起作用

import './App.css';
import "bootstrap/dist/css/bootstrap.min.css"; 
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
import "TodosList" from "./components/todos-list.component.js";

class App extends Component {
  render() {
    return (
      <Router>
        <div className="container">
          <nav className="navbar navbar-expand-lg navbar-light bg-light">
            <a class="navbar-brand" href="https://codingthesmartway.com" target="_blank"></a>
            <Link to="/" className="navbar-brand">MERN-Stack Todo App</Link>
            <div className="collpase navbar-collapse">
              <ul className="navbar-nav mr-auto">
                <li className="navbar-item">
                  <Link to="/" className="nav-link">Todos</Link>
                </li>
                <li className="navbar-item">
                  <Link to="/create" className="nav-link">Create Todo</Link>
                </li>
              </ul>
            </div>
          </nav>
          <br/>
          <Route path="/" exact component={TodosList} />
        </div>
      </Router>
    );
  }
}

export default App;

1 个答案:

答案 0 :(得分:1)

语法错误

import "TodosList" from "./components/todos-list.component.js"; 

应该是

import TodosList from "./components/todos-list.component.js";