react函数组件路由跳转
import React, { useState, useEffect } from 'react'
import { useHistory } from "react-router-dom";
import cx from 'classnames'
import './index.css'
interface resLogin {
code?: number,
data?: object
}
const Login: React.FC<{}> = (props) => {
let history = useHistory();
const onFinish = async (values: any) => {
const { username, password } = values
let result = await userLogin({ params: { username, password } }) as resLogin
if(result.code === 200){
history.push("/layout");
}
};
return (
<div className={cx('container')}>
<div className={cx('loginCard')}>
{ ... }
</div>
</div>
)
}
export default Login