[react-router.v4] Uncaught TypeError: Cannot read property 'location' of undefined

  1. 选择 react-router 和 react-router-dom
    只需引用一个,两者之处就是dom多了 这样的 DOM 类组件

  2. 报错 Uncaught TypeError: Cannot read property 'location' of undefined

impt 引用时写

import React from "react";
import { render } from "react-dom";

import { BrowserRouter as Router, Route, Link } from "react-router-dom";

const Home = () => {
  return (
    

test home

); }; const about = () => { return (

test about

); }; const topics = () => { return (

test topics

); }; render(
  • 首页
  • 关于
  • 主题列表
, document.getElementById("root") );

你可能感兴趣的:([react-router.v4] Uncaught TypeError: Cannot read property 'location' of undefined)