[英]Laravel mix, call app.js in resources
I have a web app with laravel and vuejs. 我有一个带有laravel和vuejs的Web应用程序。 I use laravel-mix and in my webpack.mix.js I have:
我使用laravel-mix,在我的webpack.mix.js中,我有:
mix.js('resources/assets/js/app.js', 'public/js')
In the view I have 我认为
<script src="{{mix('js/app.js')}}"></script>
But it still does not run, I think it could be interfered by <base href="{{asset('')}}">
card. 但是它仍然无法运行,我认为它可能会受到
<base href="{{asset('')}}">
卡的干扰。
I run npm run watch
but still no error message. 我运行
npm run watch
但仍然没有错误消息。 In my website app.js
can run but the other libraries get lost. 在我的网站上,
app.js
可以运行,但其他库却丢失了。
I always do these steps and it works please try these: 我总是按照以下步骤操作,但请尝试以下方法:
1)install laravel mix npm i
1)安装laravel mix
npm i
2)in webpack : 2)在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');
please include your css and javascript files in new files like here in admin.js and admin.scss
请在新文件中添加您的CSS和javascript文件,例如admin.js和admin.scss中的此处
3)in admin.scss include your css files for example : 3)在admin.scss中包括您的CSS文件,例如:
@import "files/sweetalert.css";
4)in admin.js include your js files for example : 4)在admin.js中包含您的js文件,例如:
mix.combine([
'files/jquery.js',
]);
5)in blade include js and css files: 5)在刀片中包括js和css文件:
<script src='js/admin.js'"></script>
<link rel="stylesheet" href="css/admin.css">
6)run npm run watch
6)运行
npm run watch
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.