繁体   English   中英

我如何在 Visual Studio 2019 中的 React Core 3.1 模板中重定向

[英]How can i redirect in react core 3.1 template in visual studio 2019

我在 Visual Studio 2019 中使用 C# Core 3.1 React 模板。问题是重定向在下面的代码中没有按预期工作。 我该如何解决这个问题?

return <Redirect to='/login'  />

这对我有用。

import { useHistory } from "react-router-dom";

const Login = () => {
    let history = useHistory();

    //button event
    const SubmitLogin = async (e: SyntheticEvent) => {
        e.preventDefault();
        history.push('/'); //redirect to home page
    }

    return (
            //your HTML return code here
        );
};

export default connect()(Login);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM