這是我的html 檔案
<button (click)="pay()">Add to Cart</button>
這是我的ts 檔案
pay(){
Swal.fire(
`Congratulations!!??`,
`<h3>The item has been added to the cart!!<h3>`,
'success');
}
因此,當我單擊“確定”(此處為成功)時,我希望用戶重定向到站點的購物車頁面。如何添加鏈接?
uj5u.com熱心網友回復:
只需使用 JavaScript 承諾。將 then 方法放在 swal 函式之后。我們不需要使用計時器功能。例如:
swal({
title: 'Request Delivered',
text: 'You can continue with your search.',
type: 'success'
}).then(function() {
window.location = "redirectURL";
})
謝謝
uj5u.com熱心網友回復:
pay(){
Swal.fire(
`Congratulations!!??`,
`<h3>The item has been added to the cart!!<h3>`,
'success').then(() => {
this.router.navigate(['/yourCartPage']);
})
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/326532.html
標籤:javascript html 有角的 打字稿 甜甜的
上一篇:使用React/Typescript使用來自React-query的資料設定狀態
下一篇:打字稿鍵入帶有資料的物件鍵
