简体   繁体   English

如何将外部js文件添加到Laravel项目的app.js文件中?

[英]How to add external js file into Laravel project app.js file?

I want to use this package for audio equalizing animation. 我想使用包进行音频均衡动画。 I want to add it in my Laravel project so I copied two files which are 我想将其添加到我的Laravel项目中,所以我复制了两个文件

jquery.reverseorder.js
jquery.equalizer.js

to /myproject/node_modules/myjss/ /myproject/node_modules/myjss/

and added these two lines 并添加了这两行

import 'myjss/jquery.equalizer'
import 'myjss/jquery.reverseorder'

into /myproject/resources/js/app.js 进入/myproject/resources/js/app.js

but it returns TypeError: $(...).equalizer is not a function 但它返回TypeError: $(...).equalizer is not a function

How can I fix it? 我该如何解决?

You don't need to save those files like that. 您无需像这样保存这些文件。 Just save them in laravel's assets folder. 只需将它们保存在laravel的资产文件夹中即可。 then in laravel, you should include it like this <script type="text/javascript" src="js/jquery.reverseorder.js"></script> . 那么在laravel中,您应该像这样<script type="text/javascript" src="js/jquery.reverseorder.js"></script>一样包含它。 in src path, you can use asset_path of laravel. 在src路径中,您可以使用laravel的asset_path。 You can include this path in js or laravel's blade template. 您可以将此路径包含在js或laravel的刀片模板中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM