Bootstrap 4离线模式Popover失效:求正确JavaScript引用链接
Bootstrap 4's Popover component won’t work without three key JavaScript files, and they must be included in the correct order. Here’s exactly what you need to set up offline:
Required Files (In This Exact Order)
- jQuery: Bootstrap 4 depends on jQuery 1.9.1 or newer. Make sure you’ve downloaded the minified version (
jquery.min.js) locally. - Popper.js: This library handles positioning for popovers and tooltips—Bootstrap 4 can’t render popovers without it. Grab
popper.min.js. - Bootstrap JS: The core Bootstrap JavaScript file (
bootstrap.min.js) that includes the popover functionality.
Example Local Script Includes
Assuming you’ve saved all these files in a js folder in your project, add these right before the closing </body> tag:
<!-- jQuery --> <script src="js/jquery.min.js"></script> <!-- Popper.js --> <script src="js/popper.min.js"></script> <!-- Bootstrap Core JS --> <script src="js/bootstrap.min.js"></script>
Initialize Popovers Manually
Even with the data-toggle="popover" attributes in your HTML, Bootstrap 4 doesn’t auto-initialize popovers by default. Add this script right after the ones above to enable all popovers on your page:
<script> $(document).ready(function() { $('[data-toggle="popover"]').popover(); }); </script>
Verify Your HTML
Your existing popover markup looks correct, but here’s a complete version to confirm all attributes are present:
<div class="container"> <h3>Popover Example</h3> <a href="#" title="Header" data-toggle="popover" data-placement="top" data-content="Content">Top</a> <a href="#" title="Header" data-toggle="popover" data-placement="bottom" data-content="Content">Bottom</a> <a href="#" title="Header" data-toggle="popover" data-placement="left" data-content="Content">Left</a> <a href="#" title="Header" data-toggle="popover" data-placement="right" data-content="Content">Right</a> </div>
Just double-check that your local file paths match where you’ve stored the JS files, and you should see popovers working offline as expected.
内容的提问来源于stack exchange,提问作者medusa eyeofskadi

