Laravel 项目的所有资产都出现 404 错误

Laravel project's all assets are giving 404 error

我正在开发一个 Laravel 项目。它低于 5.7 Laravel 版本。我使用 Homestead 作为本地开发环境。当我 运行 项目中的任何路线时,它不会加载 public 资产。相反,它给出了 404 错误。请参阅下面的附图。

我在获取资产路径时编码正确

{{ asset("public/js/frontend/jquery.min.js") }}

但所有这些资产都存在于项目文件夹中。当我尝试使用这些资产中的任何一个时,它会在图像下方给出 laravel 的 404 error.see。

如果有人能给我一个解决方案就太好了。提前致谢。

正如@Douwe de Haan 所建议的,您不必使用 public 部分,只需调用

{{ asset("js/frontend/jquery.min.js") }}

您不应该将 public 目录写入资产函数

{{ asset("js/frontend/jquery.min.js") }}

此外,

You can configure the asset URL host by setting the ASSET_URL variable in your .env file. This can be useful if you host your assets on an external service like Amazon S3:

// ASSET_URL=http://example.com/assets

$url = asset('img/photo.jpg'); // http://example.com/assets/img/photo.jpg

https://laravel.com/docs/5.8/helpers#method-asset