Laravel和Vue:将js/app.js放在哪里? [英] Laravel and Vue: where to put js/app.js?

查看:92
本文介绍了Laravel和Vue:将js/app.js放在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用一些Vue组件和一个Bootstrap组件(轮播)创建了一个简单的应用程序.

I created a simple app using some Vue components and a Bootstrap component (carousel).

我使用Laravel Mix来编译我的资产.当我将编译后的app.js放在head标签之间时,我的Vue组件不起作用(找不到元素:#app ).当我将app.js放在</body> 标记之前时,我的轮播(

I compile my assets using Laravel Mix. When I put the compiled app.js between the head tags, my Vue components 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?

当我将资产放在</body> 标记之前时,轮播的指示器如下所示:< =" li =">

When I put my asset just before the </body> tag, the indicators of the carousel looks like this: <="" li="">

推荐答案

通常,在结束</body> 标记之前.

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

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

如果您还有其他特定于引导程序的js代码,则必须在上述script标记后编写它们,因为 app.js 还负责在中加载引导程序所需的js文件.资源/资产/js/bootstrap.js 文件.

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.

这篇关于Laravel和Vue:将js/app.js放在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆