Bootstrap 4: Uncaught ReferenceError: Popper is not defined

后端 未结 8 1046
猫巷女王i
猫巷女王i 2020-11-27 17:23

I\'ve installed Bootstrap 4 using Node and Gulp and when running the application I get the following error

Uncaught ReferenceError: Popper is not def

相关标签:
8条回答
  • 2020-11-27 18:03

    For those struggling with this issue on Webpack: In your entry file,
    import 'bootstrap' does give the error. You need to remove that and replace it with import 'bootstrap/dist/js/bootstrap.bundle.js'

    This is sufficient and you don't need to import Popper separately. That applies for bootstrap 4.0.0.beta2

    0 讨论(0)
  • 2020-11-27 18:09

    For those who are here and trying to add popper v2 to Laravel

    1. in package.json at devDependencies section we have "popper.js": "^1.12", so remove this string. As official doc says they move to @popperjs scope name. If you have any v1 poppers used in project follow the migrate guide v1 to v2 from doc. UPD: this sht is required by bootstrap. so, i had to reinstall it after remove. skip this step.
    2. in console npm i @popperjs/core
    3. in bootstrap.js at try section add window.Popper = require('@popperjs/core')
    4. rebuild your js in console npm run dev
    5. ok, now you can make your instance let _instance = Popper.createPopper(element, tooltip, {})
    0 讨论(0)
提交回复
热议问题