使用此代碼,我試圖顯示所有排隊的警報。<?php if(count($_SESSION["alerts"]) >= 1){ print(" <script src='https://cdn.jsdelivr.net/npm/sweetalert2@9'></script> <script> var steps = ["); for($i = 0; $i < count($_SESSION["alerts"]); ++$i){ $title = $_SESSION["alerts"][$i][0]; $message = $_SESSION["alerts"][$i][1]; $icon = $_SESSION["alerts"][$i][2]; print(" { title:'$title', icon: '$icon', text: '$message', }, "); } print(" ]; swal.setDefaults({ confirmButtonText: 'Ok', showCancelButton: false, animation: true }); swal.queue(steps); </script> "); } $_SESSION["alerts"] = null; $_SESSION["alerts"] = array(); ?>但是,如果我在隊列中使用警報調用它,那么我會在 chrome 控制臺中看到一條錯誤消息:swal.setDefaults is not a function我怎樣才能使這段代碼按預期工作?
1 回答

慕雪6442864
TA貢獻1812條經驗 獲得超5個贊
swal.setDefaults({ }) 在 v8 中被棄用并在 v9 中被移除。使用 swal.mixins({...options});
- 1 回答
- 0 關注
- 129 瀏覽
添加回答
舉報
0/150
提交
取消