I just started working with Laravel 5.7. I know it comes with a bunch of stuff which I don't need.
In my bootstrap.js
file I only have lines for jquery
try {
window.$ = window.jQuery = require('jquery');
//require('bootstrap');
} catch (e) {}
This works fine, so I try to define global vars the way I used to do them
var example = ( function( name ) { return name; }( example || {} ) );
example.whatever..
This does not work because when I look at the compiled js, it has a bunch of webpack exported lines and whatnot, I don't really understand these or where they come from but I assume it comes from the compilation of this entire framework.
So I ended up declaring global vars like this in bootstrap.js
window.example = {};
In my files, I would do something like this
window.example.Home =...
While this works but I feel like this isn't the proper way to do it.
What's the proper way to declare global vars in js with Laravel framework?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire