admin管理员组文章数量:1312635
I am making a blogging application with Laravel 8 and Bootstrap 5. I use a form placed within a Bootstrap modal to add a post. In addition, I include a single JavaScript file in the project.
<script src="{{ asset('js/app.js') }}"></script>
In resources/js
, I have an app.js and a bootstrap.js file. In app.js, I require bootstrap.js with
require('./bootstrap')
From webpack.mix.js
I pile all that into the single JavaScript file public\js\app.js
:
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css')
.sourceMaps();
I want to add popper.js to the project, like this:
require('./popper');
require('./bootstrap');
But, for this purpose, I need the popper.js in resources/js
along with the other two files. So, I did npm i @popperjs/core
and npm run dev
. But it does not pile, and I don't get popper.js in the above-metioned js directory. So, how can I fix this issue?
I am making a blogging application with Laravel 8 and Bootstrap 5. I use a form placed within a Bootstrap modal to add a post. In addition, I include a single JavaScript file in the project.
<script src="{{ asset('js/app.js') }}"></script>
In resources/js
, I have an app.js and a bootstrap.js file. In app.js, I require bootstrap.js with
require('./bootstrap')
From webpack.mix.js
I pile all that into the single JavaScript file public\js\app.js
:
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css')
.sourceMaps();
I want to add popper.js to the project, like this:
require('./popper');
require('./bootstrap');
But, for this purpose, I need the popper.js in resources/js
along with the other two files. So, I did npm i @popperjs/core
and npm run dev
. But it does not pile, and I don't get popper.js in the above-metioned js directory. So, how can I fix this issue?
2 Answers
Reset to default 71 - Install @popperjs/core
using this mand: npm i @popperjs/core
2 - Add this line to your bootstrap.js
file:
window.Popper = require('@popperjs/core');
3 - Run this mand: npm run dev
4 - Now you have access to window.Popper
in your blade files.
In your resources/js/bootstrap.js file, you can use Popper.js and Bootstrap with jQuery like the following.
window._ = require('lodash');
try {
window.$ = window.jQuery = require('jquery');
window.Popper = require('@popperjs/core');
window.bootstrap = require('bootstrap');
} catch (exception) {
console.error(exception);
}
本文标签: javascriptHow do I add popperjs to a Laravel 8 with Bootstrap 5 projectStack Overflow
版权声明:本文标题:javascript - How do I add popper.js to a Laravel 8 with Bootstrap 5 project? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741921089a2405009.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论