简体   繁体   English

如果基础 URL 有子文件夹,如何在 Vue.js 和 Laravel 中引用 app.js

[英]How to reference app.js in Vue.js with Laravel mix if base URL have sub folder

My Laravel web application domain is like www.mywebsite.com/my-project/public and I don't want to change.我的 Laravel web 应用程序域就像www.mywebsite.com/my-project/public ,我不想更改。

I installed Vue.js by npm install && npm run dev and try to reference app.js by我通过npm install && npm run dev并尝试通过引用 app.js

<script src="{{mix('js/app.js')}}"></script>

but I got error www.mywebsite.com/js/app.js net::ERR_ABORTED 404 (Not Found)但我收到错误www.mywebsite.com/js/app.js net::ERR_ABORTED 404 (Not Found)

I try to config path in webpack.min.js我尝试在 webpack.min.js 中配置路径

mix.js('my-project/resources/assets/js/app.js', 'public/js')
   .sass('my-project/resources/assets/sass/app.scss', 'public/css');

but I think it's not way to fix... Please help me thank you.但我认为这不是解决方法......请帮助我,谢谢。

You may do so by adding a mix_url configuration option to your application's config/app.php configuration file:您可以通过在应用程序的 config/app.php 配置文件中添加 mix_url 配置选项来实现:

'mix_url' => env('MIX_ASSET_URL', null)

Reference参考

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

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