Bootstrap 4 确认无效,有什么问题吗?

Bootstrap 4 Confirmation is not working, what is wrong with it?

我在我的项目中添加了 bootstrap 4 确认,但是即使我添加了源等也无法正常工作...

有什么问题吗?

我的代码:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/bootstrap-confirmation2/dist/bootstrap-confirmation.min.js"></script>


<div class="m-4">
<button class="btn btn-primary" data-toggle="confirmation">Confirmation</button>
</div>

我正在使用这个“BS-4-Confirmation”确认插件...

您需要通过 javascript 启用确认,如下所示。

$('[data-toggle=confirmation]').confirmation({
   rootSelector: '[data-toggle=confirmation]'
});

我已将您的代码段更改为有效,它会起作用。

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap-confirmation2/dist/bootstrap-confirmation.min.js"></script>

<div class="m-4">
<button class="btn btn-primary" data-toggle="confirmation">Confirmation</button>
</div>

<script>
$('[data-toggle=confirmation]').confirmation({
   rootSelector: '[data-toggle=confirmation]'
});
</script>