点击 x
时通知不会消失。
我认为没有缺少任何必需的 css 类,所以我不确定为什么这不起作用。
在点击x
之前:
点击x
后:
application.html.erb
<html>
<body>
...
<% if flash[:notice] %>
<div class="alert alert-success alert-dismissible fade out in">
<button type="button" class="close" data-dismiss="alert">
<span>×</span>
</button>
<%= flash[:notice] %>
</div>
<% elsif flash[:error] %>
<div class="alert alert-danger alert-dismissible fade out in">
<button class="close" data-dismiss="alert">×</button>
<% flash[:error].each do |msg| %>
<li>
<%= msg %>
</li>
<% end %>
</div>
<% elsif flash[:alert] %>
<div class="alert alert-warning alert-dismissible fade out in">
<button type="button" class="close" data-dismiss="alert">×</button>
<%= flash[:alert] %>
</div>
<% end %>
</body>
</html>
Gemfile.rb
gem 'bootstrap-sass'
application.scss
@import 'bootstrap-sprockets';
@import 'bootstrap';
还有什么可以推荐我尝试的吗?
最佳答案
解决方案。
将 //= require bootstrap-sprockets
添加到 application.js。
我不知道除了 @import 'bootstrap-sprockets';
在 application.scss
中这是必需的
关于css - 在 Rails 应用程序中单击 `x` 时 Bootstrap 警报不会解除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39935581/