Skip to content Skip to sidebar Skip to footer

Laravel And Vue: Where To Put Js/app.js?

I created a simple app using some Vue components and a Bootstrap component (carousel). I compile my assets using Laravel Mix. When I put the compiled app.js between the head tags,

Solution 1:

In general, before the ending </body> tag.

<script type="text/javascript" src="/js/app.js"></script>

And if you have other bootstrap specific js codes, you have to write them after the above-mentioned script tag because app.js is also responsible for loading bootstrap required js files in the resources/assets/js/bootstrap.js file.


Solution 2:

The message Cannot find element: #app does not mean, that vue do not work. It means, that Vue.js is mounted correctly but it can not find any div with the id of app:

<div id="app"></div>

To include an js file I would recommend the asset() helper:

<script type="text/javascript" src="{{ asset('js/app.js') }}"></script>

Post a Comment for "Laravel And Vue: Where To Put Js/app.js?"