import {Button, Card, Form} from "react-bootstrap"; import {useContext, useState} from "react"; import axios from "axios"; import {server} from "../config"; import {resCode, successTime} from "../utils/util"; import {toast} from "react-toastify"; import {UserContext} from "../utils/userContenxt"; import Router from "next/router"; import jsCookie from "js-cookie"; const login = () => { const [uname, setUname] = useState(''); const [pwd, setPwd] = useState(''); const {user, setUser} = useContext(UserContext); async function submitLogin() { const res = await axios.post(`${server}/admin/login`, {uname: uname, pwd: pwd}) const {code, msg, data} = await res.data if (resCode(code, msg)) return jsCookie.set('token', data.token) setUser(data) toast.success('登录成功', {autoClose: successTime}) await Router.push("/") } return () } export default loginLogin 用户名 setUname(event.target.value)}/> Password setPwd(event.target.value)}/>
2021年12月4日星期六
login.js
订阅:
博文评论 (Atom)
-
import '../styles/globals.css' import 'bootstrap/dist/css/bootstrap.min.css'; import 'react-toastify/dist/ReactToastif...
-
sudo apt update sudo apt install openjdk-11-jdk java -version
-
心情 伤心 万念俱灰 伤心欲绝 五内如焚 肝肠寸断 触景伤心 闷闷不乐 哭泣 泣不成声 泪如雨下 抱头大哭 撕心裂肺 哀天叫地 着急 心急如焚 坐立不安
没有评论:
发表评论