javascript - Laravel newly added javascript files give an error net::ERR_ABORTED 404 (Not Found)
问题描述
In my laravel application, it gives an error with a net:: ERR_ABORTED 404 (Not Found). I have added the javascript files into the
resources\assets\js\customjsfile.js
.
And I'm calling the file like this.
<script src="{{ asset('js/customjsfile.js') }}"></script>
Other js files such as app.js are loading.
解决方案
asset()
function takes path from the /public
folder by default. if you are using laravel mix then you should update your webpack.mix.js
file otherwise you can directly put the file in /pubilc/js
folder.
In webpack.mix.js:
mix.js('resources/js/customfile.js', 'public/js');
Then run
npm run dev // for development
npm run production // for production
for this
"Other js files such as app.js are loading."
app.js
file is already defined in the webpack.mix.js
推荐阅读
- ckan - 用于获取特定字段的 CKAN 数据存储搜索不起作用
- html - 为什么这些按钮之间会显示一条线?
- sql-server - DAX 中每个 ID 的最近一个月数据
- python - Scrapy-Splash 不呈现此页面
- sql - 为某些条件 SQL Server 引发错误/引发异常
- jquery - Foundation 6.5 向下钻取动态返回文本会破坏数据自动高度
- cpanel - CPanel - 带有希腊 TLD .ελ 的插件域
- wpf - 如何创建负角半径
- android - 如何获取没有变量的 JSONArray?
- angular - Angular 5 - 使用模板驱动表单的动态表单验证