简体   繁体   English

Popper,Bootstrap 4和ES2015:未定义Popper

[英]Popper, Bootstrap 4 and ES2015: Popper not defined

I am pretty confused on how to make the Javascript utilities in Bootstrap 4 work. 我对如何使Bootstrap 4中的Javascript实用程序感到困惑。

I am using ES2015 style requires. 我正在使用ES2015样式要求。 I've installed jQuery, the latest beta of Bootstrap 4 (beta 2) and Popper.js using node modules. 我已经使用节点模块安装了jQuery,Bootstrap 4(beta 2)和Popper.js的最新Beta。 Here's how I am loading my JS: 这是我加载JS的方法:

window.$ = window.jQuery = require('jquery');

$(function() {

  require('popper');
  require('./vendor/bootstrap/index');

});

Popper's docs state that you need code like this to instantiate Popper: Popper的文档指出,您需要这样的代码来实例化Popper:

  var reference = document.querySelector('#dropdownLanguageButton');
  var popper = document.querySelector('div[aria-labelledby="dropdownLanguageButton"]');
  var anotherPopper = new Popper(
      reference,
      popper,
      {
          // popper options here
      }
  );

However, it is not clear if you need to instantiate for something as simple as a Bootstrap dropdown. 但是,尚不清楚是否需要实例化Bootstrap下拉列表等简单内容。

There is no clear example in the Bootstrap 4 docs. Bootstrap 4文档中没有明确的示例。

The error I am getting is index.js:10 Uncaught ReferenceError: Popper is not defined . 我得到的错误是index.js:10 Uncaught ReferenceError: Popper is not defined

Help appreciated! 帮助赞赏!

Maybe problem in path to popper.js. 可能是popper.js的路径问题。 Popper's required file located in 'node_modules/popper.js/dist/umd/popper.min.js' Popper的必需文件位于“ node_modules / popper.js / dist / umd / popper.min.js”中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM