我正在 React 中构建一个响应式导航栏,当您放大页面时,它会隐藏链接并显示一个带有带有链接的下拉列表的按钮。
问题是,当我单击按钮时,它不会执行任何操作,并且在引导网站中,它可以正常运行。
我做错了什么吗?
这是我的代码:
import React, { Component } from 'react';
import axios from "axios";
import { Redirect } from "react-router-dom"
import styles from '../styles/loginsignup.css'
import logo from '../img/nowyourguest.png'
import 'bootstrap/dist/css/bootstrap.min.css'
import 'jquery/dist/jquery.min.js'
import 'bootstrap/dist/js/bootstrap.min.js'
export default class Login extends Component {
state = {
email: '',
password: ''
};
handleSubmit = event => {
event.preventDefault();
const {email, password} = this.state;
axios({
url: "/authentication/signin",
method: "POST",
data: {
email,
password
}
})
.then(response => {
const isAuthenticated = response.data.isAuthenticated
window.localStorage.setItem('isAuthenticated', isAuthenticated);
this.props.history.push('/profile')
})
.catch(error => {
this.setState({
errorMessage: error.response.data.message
})
})
};
handleChange = event => {
const {name, value} = event.target;
this.setState({
[name]: value
})
}
render() {
const isAuthenticated = window.localStorage.getItem('isAuthenticated');
if (isAuthenticated) {
return <Redirect to='/profile'/>
}
缥缈止盈
忽然笑
MMMHUHU
相关分类