react 基础路由配置,404界面配置

安装
npm install --save react-router-dom
基础使用
import React from 'react';
//界面组件
import Home from './pages/home';
import Login from './pages/Login';
//引入需要用到模块
import { BrowserRouter as Router, Route} from "react-router-dom";

function router(){
return (

    
    
);
}

export default router;
添加404
import React from 'react';
//界面组件
import Home from './pages/home';
import Login from './pages/Login';
import NotFound from './pages/notfound';
//引入需要用到模块
import { BrowserRouter as Router, Route, Switch} from "react-router-dom";

function router(){
return (

    
        
        
        
    
);
}

export default router;

的作用是保证只会渲染一个路径

你可能感兴趣的:(react-router)