我刚刚升级到 Bootstrap 4 并实现了 Popper.js是一种依赖。我喜欢在本地托管库,因为我有时需要离线工作,但当我尝试离线使用它时,我收到错误消息 unexpected token export
。但是,当我使用 Cloudflare CDN 版本时它可以工作,但我如何在本地托管 popper.js?
(我不想为此使用包管理器。)
最佳答案
README.md of the project将有助于解决这个问题:
Dist targets
Popper.js is currently shipped with 3 targets in mind: UMD, ESM and ESNext.
- UMD - Universal Module Definition: AMD, RequireJS and globals;
- ESM - ES Modules: For webpack/Rollup or browser supporting the spec;
- ESNext: Available in
dist/
, can be used with webpack andbabel-preset-env
;Make sure to use the right one for your needs. If you want to import it with a
<script>
tag, use UMD.
因此,如果您想将 Popper.js 与 <script />
一起使用标签,你想使用 umd
它的版本。位于 dist/umd
.
关于javascript - 如何在本地托管 popper.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46313043/