admin管理员组文章数量:1332359
I created a simple app using some Vue ponents and a Bootstrap ponent (carousel).
I pile my assets using Laravel Mix. When I put the piled app.js between the head tags, my Vue ponents do not work (Cannot find element: #app
). When I put the app.js just before the </body>
tag, my carousel (the indicators) does not work ... I also tried with the defer
attribute, but no success. Do I have to split my JavaScript-files to make both work?
Edit:
When I put my asset just before the </body>
tag, the indicators of the carousel looks like this: <="" li="">
I created a simple app using some Vue ponents and a Bootstrap ponent (carousel).
I pile my assets using Laravel Mix. When I put the piled app.js between the head tags, my Vue ponents do not work (Cannot find element: #app
). When I put the app.js just before the </body>
tag, my carousel (the indicators) does not work ... I also tried with the defer
attribute, but no success. Do I have to split my JavaScript-files to make both work?
Edit:
When I put my asset just before the </body>
tag, the indicators of the carousel looks like this: <="" li="">
2 Answers
Reset to default 4In 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.
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 remend the asset()
helper:
<script type="text/javascript" src="{{ asset('js/app.js') }}"></script>
本文标签: javascriptLaravel and Vue where to put jsappjsStack Overflow
版权声明:本文标题:javascript - Laravel and Vue: where to put jsapp.js? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742318074a2452216.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论