Bootstrap Dropdown在React中不起作用 [英] Bootstrap Dropdown is not working in React

查看:64
本文介绍了Bootstrap Dropdown在React中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我包含了一个从Bootstrap Dropdowns下拉到React的下拉按钮,但是它不起作用,显示为普通按钮.你能给我一个解决方案吗?

I include a dropdown button to React from bootstrap Dropdowns, But it is not working and shows as a normal button. Can you give me a solution for this?

<div className="dropdown">
    <button className="btn btn-secondary 
                 dropdown-toggle" 
                 type="button" 
                 id="dropdownMenuButton"
                 data-toggle="dropdown"
                 aria-haspopup="true" 
                 aria-expanded="false">
                 Dropdown button
    </button>
            <div className="dropdown-menu" aria-labelledby="dropdownMenuButton">
                <a className="dropdown-item" href="#">Action</a>
                <a className="dropdown-item" href="#">Another action</a>
                <a className="dropdown-item" href="#">Something else here</a>
            </div>
</div>

输出是一个像这样的普通按钮.

The output is a normal button like this.

推荐答案

没有 popper.js jquery.js ,下拉菜单将无法正常工作.

Dropdowns are not working without popper.js and jquery.js.

因此,请使用 npm install popper.js jquery --save 在系统中安装 popper.js jquery.js ,并且不要别忘了包含它.

So please install popper.js and jquery.js in your system using npm install popper.js jquery --save and don't forget to include it.

使用CDN

https://stackblitz.com/edit/create-react-class-m3qfxu?file = index.html

使用NPM

https://stackblitz.com/edit/create-react-class-xvsthx?file = index.js

这篇关于Bootstrap Dropdown在React中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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