-6ren">
gpt4 book ai didi

javascript - 如何将链接传递给react ant design模型 "Confirm/yes/ok "点击按钮

转载 作者:行者123 更新时间:2023-12-03 01:33:03 26 4
gpt4 key购买 nike

这里我的问题是当我单击按钮来显示此模型时。当我单击模型按钮“确定”时,我需要传递链接,此链接转到..我该怎么办?

image

这是我的按钮代码:

   <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');
},
});
}

关于javascript - 如何将链接传递给react ant design模型 "Confirm/yes/ok "点击按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51194344/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com