gpt4 book ai didi

twitter-bootstrap - Bootstrap 4 Beta - 是否需要 Popper.js?

转载 作者:行者123 更新时间:2023-12-03 21:06:05 25 4
gpt4 key购买 nike

如果我不使用下拉菜单,我想问一下 Popper.js 是否绝对必要。
如果没有库,是否还有其他由 popper 驱动的部分无法工作?

最佳答案

如果您在 Bootstrap 4's documentation 中搜索“popper” ,会出现以下结果:

Tooltips rely on the 3rd party library Popper.js for positioning.

Popovers rely on the 3rd party library Popper.js for positioning.

Dropdowns are built on a third party library, Popper.js, which provides dynamic positioning and viewport detection.


所以这些是需要 Popper.js 的 Bootstrap 4 组件。
虽然 Popper.js 被声明为 Bootstrap 4 的要求,并且 Bootstrap 4 JS 如果找不到 Popper 则会记录错误, 如果您不需要工具提示、弹出框、下拉菜单或模式,您仍然可以在没有 Popper 的情况下使用 Bootstrap 4 JS。
例如导航栏的 JS 功能(右侧的移动菜单)运行良好:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>

关于twitter-bootstrap - Bootstrap 4 Beta - 是否需要 Popper.js?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46155017/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com