单击关闭按钮时,我的 Bootstrap 警报框未关闭 [英] My Bootstrap Alert box does not close when dismiss button is clicked

查看:35
本文介绍了单击关闭按钮时,我的 Bootstrap 警报框未关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向我的 React 元素添加一个可关闭的引导程序警报框.我相信我的所有内容都按顺序排列,但是当我单击 X 时,它不会关闭.

这是 React 特有的问题吗?还是我没有使用正确的语法?

解决方案

在使用 Bootstrap 4 时遇到了这个问题,并通过向 index.js

添加以下行来解决

import 'bootstrap/dist/js/bootstrap';

I am trying to add a dismissable bootstrap alert box to my React element. I believe I have everything in proper order, but when I click the X, it will not close.

<div id="index-alert" className="alert alert-danger alert-dismissable">
  <button type="button" className="close" data-dismiss="alert" aria-hidden="true"></button>
  {this.getIntlMessage('contactsInfoAlert')}
</div>

Is this a React specific problem? Or am I not using the proper syntax?

解决方案

Had this issue using Bootstrap 4 and it was resolved by adding the following line to index.js

import 'bootstrap/dist/js/bootstrap';

这篇关于单击关闭按钮时,我的 Bootstrap 警报框未关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆