如何在 Sweet Alert 2 中更改 focused/pressed 按钮的颜色?

How to change the color of a focused/pressed button in Sweet Alert 2?

对于 Sweet Alert 2 弹出确认 window,如果我将属性 "allowEnterKey" 设置为默认值 true,则当 [=22] =] 弹出。此外,此按钮的颜色将不同于其常规颜色(例如,未聚焦或未按下时的颜色)

另一方面,如果我将 "allowEnterKey" 设置为 false,则此按钮将不会突出显示,颜色将是其常规颜色。但是用户将无法通过按回车键关闭window,这对我来说不是很理想。

那么,如何将按钮的颜色更改为聚焦时的常规颜色?

A sample pop-up confirmation window, where the button is highlighted and grey instead of its regular color blue

documentation 指定颜色选项:confirmButtonColorcancelButtonColor

swal({
  title: 'Are you sure?',
  text: "You won't be able to revert this!",
  type: 'warning',
  showCancelButton: true,
  confirmButtonColor: '#3085d6',
  cancelButtonColor: '#d33',
  confirmButtonText: 'Yes, delete it!'
}).then((result) => {
  if (result.value) {
    swal(
      'Deleted!',
      'Your file has been deleted.',
      'success'
    )
  }
})

如果这还不够,您还可以应用自定义 CSS 类,例如:

confirmButtonClass: 'btn btn-success',
cancelButtonClass: 'btn btn-danger',