react 路由权限

import {  Spin } from "antd";
import { Suspense } from "react";
import { Navigate } from "react-router-dom";
import KeepAlive from 'react-activation'
function AuthRoute(props: any) {
    const spinStyle = {
        width: '100%',
        height: '100%',
        display: 'flex',
        alignItems: 'center',
        justifyContent: 'center'
    }
    const token = localStorage.getItem("token");

    let template = ;

    if (token || !props.auth) {
        if (props.id) {
            template = 
                
}>{props.children} } else { template =
} >{props.children} } } return template } export default AuthRoute

 使用方式

react 路由权限_第1张图片

你可能感兴趣的:(react.js,javascript,前端)