React Router正在更改url,但未加载组件。
更改网址后,如果刷新页面,则会显示与该网址对应的正确组件。
这是代码:
import React from "react";
import { Route, Switch } from "react-router-dom"
import { Link, BrowserRouter as Router } from 'react-router-dom'
import {Home} from '../src/Views/Home';
import {Test} from './Views/Home';
import App from '../../../src/App'
const Root = () => (
<Router>
<Switch>
<Route exact path="/" component={Home}/>
<Route exact path="/test" component={Test} />
</Switch>
</Router>
);
export default Root;
没有控制台错误。