gpt4 book ai didi

javascript - React-router-dom 给出错误

转载 作者:行者123 更新时间:2023-11-28 18:03:51 25 4
gpt4 key购买 nike

我有以下“react-router-dom”的实现,但我无法让它工作。有人可以指导我根本问题是什么吗?

App.jsx

import React from "react";
import Main from "../components/Main";
import Home from "../components/Home";
import { BrowserRouter, Match, Miss, Link } from 'react-router-dom';


const App = () => (

<BrowserRouter>
<div>
<Match exactly pattern="/" component={Main} />
<Match pattern="/home" component={Home} />
</div>
</BrowserRouter>
);

export default App;

Index.jsx

import React from "react";
import ReactDOM from "react-dom";
import Main from "./components/Main";
import Home from "./components/Home";

import Page from './components/Page';
import App from "./config/App";


ReactDOM.render(
<App/>,
document.getElementById('app')
);

我收到以下错误: enter image description here

最佳答案

请引用docs of React Router v4

MatchMiss 来自以前版本的react-router-v4.alpha

当前稳定版本的 v4.您应该使用Route 而不是Match小姐已经不在了。

我认为这应该可以解决您的问题。

关于javascript - React-router-dom 给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43045107/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com