如何在 Bootstrap 4 测试版中使用 Popper.js [英] How to use Popper.js with Bootstrap 4 beta

查看:17
本文介绍了如何在 Bootstrap 4 测试版中使用 Popper.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是老学生,所以我将源代码下载到 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 包可以通过

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