Laravel混合,在资源中调用app.js [英] Laravel mix, call app.js in resources
问题描述
我有一个带有laravel和vuejs的Web应用程序.我使用laravel-mix,并在我的webpack.mix.js中拥有:
I have a web app with laravel and vuejs. I use laravel-mix and in my webpack.mix.js I have:
mix.js('resources/assets/js/app.js', 'public/js')
我认为
<script src="{{mix('js/app.js')}}"></script>
但是它仍然无法运行,我认为它可能会受到< base href ="{{asset('')}}">
卡的干扰.
But it still does not run, I think it could be interfered by <base href="{{asset('')}}">
card.
我运行 npm run watch
,但仍然没有错误消息.在我的网站中, app.js
可以运行,但是其他库丢失了.
I run npm run watch
but still no error message. In my website app.js
can run but the other libraries get lost.
推荐答案
我总是按照以下步骤操作,但请尝试以下方法:
I always do these steps and it works please try these:
1)安装laravel mix npm i
1)install laravel mix npm i
2)在webpack中:
2)in webpack :
mix.js('resources/assets/js/app.js', 'public/js');
mix.js('resources/assets/js/admin.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
.sass('resources/assets/sass/admin.scss', 'public/css');
请在新文件中添加您的CSS和javascript文件,例如admin.js和admin.scss中的
please include your css and javascript files in new files like here in admin.js and admin.scss
3)在admin.scss中包括您的css文件,例如:
3)in admin.scss include your css files for example :
@import "files/sweetalert.css";
4)在admin.js中包含您的js文件,例如:
4)in admin.js include your js files for example :
mix.combine([
'files/jquery.js',
]);
5)刀片中包含js和css文件:
5)in blade include js and css files:
<script src='js/admin.js'"></script>
<link rel="stylesheet" href="css/admin.css">
6)运行 npm运行监视
这篇关于Laravel混合,在资源中调用app.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!