如何在 Bootstrap 4 测试版中使用 Popper.js [英] How to use Popper.js with Bootstrap 4 beta
问题描述
我是老学生,所以我将源代码下载到 1.12.0,然后执行以下操作:
I'm old school, so I downloaded the source code to 1.12.0 and then did the following:
<script src="/popper.js-1.12.0/dist/popper.js"></script>
<script src="/bootstrap-4.0.0-beta/dist/js/bootstrap.js"></script>
但我得到:
Uncaught SyntaxError: Unexpected token export
在线 2294
上面写着:
export default Popper;
推荐答案
您想使用 package.json
文件作为 main
条目.
You want to use the dist target specified in the package.json
file as main
entry.
在这种情况下,您正在寻找 umd
构建 (dist/umd/popper.js
)
In this case, you are looking for the umd
build (dist/umd/popper.js
)
UMD 模式 通常试图提供与当今最流行的脚本加载器(例如 RequireJS在其他人中).在许多情况下,它使用 AMD 作为基础,并添加了特殊的外壳来处理 CommonJS 兼容性.
The UMD pattern typically attempts to offer compatibility with the most popular script loaders of the day (e.g RequireJS amongst others). In many cases it uses AMD as a base, with special-casing added to handle CommonJS compatibility.
这意味着 UMD 包可以通过 标签加载并注入到全局范围内(
window
),但如果需要,也可以使用CommonJS 加载器,例如 RequireJS.
This means that an UMD bundle can be loaded via <script>
tag and get injected inside the global scope (window
), but also work if required with a CommonJS loader such as RequireJS.
这篇关于如何在 Bootstrap 4 测试版中使用 Popper.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!