Explorar o código

路由修改测试1

zhouna %!s(int64=3) %!d(string=hai) anos
pai
achega
040e003af9
Modificáronse 2 ficheiros con 5 adicións e 3 borrados
  1. 1 0
      src/components/AuthIndex/index.js
  2. 4 3
      src/components/Login/index.js

+ 1 - 0
src/components/AuthIndex/index.js

@@ -3,6 +3,7 @@ import {
     Switch,
     Route,
     Redirect,
+    withRouter
 } from "react-router-dom";
 /*import NullPage from '@components/NullPage';
 import Login from '@components/Login';

+ 4 - 3
src/components/Login/index.js

@@ -4,12 +4,12 @@ import apiObj from '@api/index';
 import { add } from '@reducers/userInfo'
 
 const {post,api} = apiObj;
-function Login() {
+function Login({history}) {
     /*useEffect(() => {
         login();
     });*/
     //const dispatch = useDispatch();
-    function login(){
+    function getLogin(){
         post(api.login,{
             "password": "a123456",
             "username": "admin"
@@ -19,11 +19,12 @@ function Login() {
                 const data = res.data.data;
                 //dispatch(add(res.data.data))
                 localStorage.setItem('token',data.token);
+                history.push('/manage')
             }
         })
     }
     return (
-        <button onClick={login}>登录</button>
+        <button onClick={getLogin}>登录</button>
     )
 }