我关注了这篇文章https://www.bootrails.com/blog/rails-7-bootstrap-5-tutorial/在我的 Rails 7.0 应用程序上显示引导警报。
当我单击关闭按钮时,警报已显示但未消除。 这是我在 application.html.erb 中的代码
<% flash.each do |key, value| %>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<%= value %>
</div>
<% end %>
最佳答案
Bootstrap 5.1 有 data-bs-dismiss
属性,而不是 data-dismiss
。确保您有“警报”插件。根据他们的文档,Bootstrap编译的javascript有它。
https://getbootstrap.com/docs/5.1/components/alerts/#dismissing https://getbootstrap.com/docs/5.1/getting-started/download/#compiled-css-and-js
关于ruby-on-rails - Rails 7 Bootstrap 警报未被消除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70972434/