如何在Bootstrap 4 Beta中使用Popper.js [英] How to use Popper.js with Bootstrap 4 beta
问题描述
我是高中,所以我将源代码下载到1.12.0,然后执行以下操作:
<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;
您要使用 UMD模式通常尝试提供与当今最流行的脚本加载器(例如RequireJS)的兼容性.在其他人中).在许多情况下,它以AMD为基础,并添加了特殊外壳来处理CommonJS兼容性.
这意味着可以通过<script>
标签加载UMD捆绑包并将其注入到全局范围(window
)中,但是如果需要CommonJS加载器(如RequireJS),也可以使用.
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>
But I'm getting:
Uncaught SyntaxError: Unexpected token export
on line 2294
where it says:
export default Popper;
You want to use the dist target specified in the package.json
file as main
entry.
In this case, you are looking for the umd
build (dist/umd/popper.js
)
What's UMD?
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.
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 Beta中使用Popper.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!