0
我正在嘗試重定向到我的reactjs項目的成功場景中的另一個頁面。我已經嘗試了以下方法解釋的方式來做到這一點,但沒有成功重定向到reactjs中的另一個頁面無法正常工作
this.props.router.push('/home');
this.context.router.push('/home');
this.history.pushState(null, 'home');
browserHistory.push('/home');
以及在stackoverflow上找到的很多其他方式。我怎樣才能成功地做到這一點。
我的代碼
function handleLoginResponse(response){
switch (response.data.response){
case "200":
/**
* in sccuess senario
* redirect to the home page
* set cookies for token and user id create session
* */
this.history.pushState(null, 'home');
break;
case "201":
console.log("201");
break;
case "202":
console.log("202");
break;
case "203":
console.log("203");
break;
case "204":
console.log("204");
break;
case "205":
console.log("205");
break;
case "206":
console.log("206");
break;
}
}
我想重定向到另一個頁面時,我得到的「200」
感謝您的答覆。
什麼是你潰敗成分是什麼樣子? – abdul
您正在使用哪個版本的react-router? –