Javascript 如何将链接传递到react ant设计模型”;确认/是/确定”;点击按钮
这里我的问题是当我点击按钮显示这个模型时。我需要通过链接时,我点击模型按钮“确定”这个链接去..我该怎么办 这是我的按钮代码:Javascript 如何将链接传递到react ant设计模型”;确认/是/确定”;点击按钮,javascript,reactjs,Javascript,Reactjs,这里我的问题是当我点击按钮显示这个模型时。我需要通过链接时,我点击模型按钮“确定”这个链接去..我该怎么办 这是我的按钮代码: <Button onClick={this.showConfirm} style={{ color: '#036cd2',verticalAlign:'middle', borderColor: '#ffffff', backgroundColor: '#ffffff', border: 0, visibility: this.props.colBtn,m
<Button onClick={this.showConfirm} style={{ color: '#036cd2',verticalAlign:'middle', borderColor: '#ffffff', backgroundColor: '#ffffff', border: 0, visibility: this.props.colBtn,marginRight:5 }} shape={'circle'}><Icon type="poweroff" /></Button>
这是我的注销功能:
showConfirm=() =>{
confirm({
title: 'Do You Want to Logout...?',
onOk() {
console.log('Ok');
},
onCancel() {
console.log('Cancel');
},
});
}
logout(){
var accessToken =localStorage.getItem('access_token');
if(!accessToken){
axios.post(`${Config.serverUrl}/api/Employes/logout?access_token=${accessToken}`, null).then((response) =>{
localStorage.clear();
});
}else {
message.error('access token required ');
}
}
这种编码在没有模型的情况下工作。我需要(与模型)当我点击“确定”按钮链接和注销功能必须工作
{ <Link to="/user-login" ><Button onClick={this.logout} style={{ color: '#036cd2',verticalAlign:'middle', borderColor: '#ffffff', backgroundColor: '#ffffff', border: 0, visibility: this.props.colBtn,marginRight:5 }} shape={'circle'}><Icon type="poweroff" /></Button></Link> }
{}
您不必在那里添加链接。您只需在onOk
中调用您的logout()
showConfirm=() =>{
confirm({
title: 'Do You Want to Logout...?',
onOk() {
logout();
},
onCancel() {
console.log('Cancel');
},
});
}
@卢卡你好,先生?先生不工作了。。。这里没有提供链接(“/user login”)?对不起,没有得到您的链接。你说,这个编码在没有模型的情况下工作。
?@Rohith Murali先生。.我需要模型这意味着当我点击模型“ok”按钮时,这些函数必须工作onOk()
当你点击ok时被调用,所以我在回答中提到的onOk
中调用注销函数就足够了“好的”按钮没有任何事情发生。