亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 ReactJS 中登錄頁面后重定向/轉到用戶配置文件

如何在 ReactJS 中登錄頁面后重定向/轉到用戶配置文件

慕尼黑5688855 2021-06-29 17:54:21
我想重定向到User Profile頁面,一旦用戶使用有效的登錄username和password但是當我單擊Login按鈕時,它不會轉到User Profile(但它會url按預期更改(http://localhost:3000/instructor/banuka)它還應該顯示InstructorLoginFormComponent它沒有顯示的內容。當我點擊什么都沒有發生但我能看到的仍然是login頁面這是我的 InstructorLoginForm.jsximport React, { Component } from "react";import { BrowserRouter as Router, Route, Switch } from "react-router-dom";import InstructorProfile from "./instructor-profile";import InstructorLoginFormComponent from "./instructor-login-form-component";export default class InstructorLoginForm extends Component {  constructor(props) {    super(props);    this.state = {      username: "",      password: ""    };    this.onChangeUsername = this.onChangeUsername.bind(this);    this.onChangePassword = this.onChangePassword.bind(this);    this.handleOnClick = this.handleOnClick.bind(this);  }  onChangeUsername(e) {    this.setState({      username: e.target.value    });  }  onChangePassword(e) {    this.setState({      password: e.target.value    });  }  handleOnClick(e) {    e.preventDefault();    const path = `/instructor/${this.state.username}`;    this.props.history.push(path);  }
查看完整描述

2 回答

  • 2 回答
  • 0 關注
  • 229 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號