[英]"NetworkError: 404 Not Found in laravel 5.1
當我單擊一個鏈接時,我已經得到了數據,但是我的css頁面,Js文件和圖像不起作用。 下面我提到鏈接,路由,控制器和錯誤(Firebug控制台)。 請幫助我清除此錯誤。
頁面鏈接
<a href="customersocialpage/<?php echo $searchCustomer->customer_id; ?>"><?php echo ucfirst($searchCustomer->firstname); ?></span> <?php echo ucfirst($searchCustomer->lastname); ?></h5></a>
routes.php
$router->get('customersocialpage/{id}', ['as' => 'custsocialpage', 'uses' => 'CustomersocialpageController@index']);
CustomersocialpageController.php
public function index($id)
{
dd($id);
$customersocialpages = Customeraddress::where('customer_id', $id)->first();
return view('pages.customersocialpage',['customersocialpages' => $customersocialpages]);
}
錯誤
"NetworkError: 404 Not Found - http://baselaravel.dev/customersocialpage/assets/img/demo/calendar_app.svg"
鏈接到CSS
{!!HTML::style('assets/plugins/pace/pace-theme-flash.css')!!}
{!!HTML::style('assets/plugins/boostrapv3/css/bootstrap.min.css')!!}
{!!HTML::style('assets/plugins/font-awesome/css/font-awesome.css')!!}
鏈接到JS
{!!HTML::script('assets/plugins/imagesloaded/imagesloaded.pkgd.min.js')!!}
{!!HTML::script('assets/plugins/jquery-isotope/isotope.pkgd.min.js')!!}
{!!HTML::script('assets/plugins/classie/classie.js')!!}
{!!HTML::script('assets/plugins/codrops-stepsform/js/stepsForm.js')!!}
所有的css,圖片和js都位於公用文件夾中
當您使用絕對鏈接時,您似乎使用了到資產的相對鏈接(例如<a href="somelink"><img src="assets/img/demo/calendar_app.svg">Link</a>
):
<a href="somelink"><img src="/assets/img/demo/calendar_app.svg">Link</a>
或者,以更Laravel'ish的方式:
<a href="{{ route('customersocialpage.index', $searchCustomer->customer_id) }}"><img src="{{ asset('assets/img/demo/calendar_app.svg') }}">Link</a>
更新。
修正您的{!!HTML::style('assets/plugins/pace/pace-theme-flash.css')!!}
鏈接到絕對鏈接,或使用SerafimArts / Asset包,它將允許您鏈接頁面上的資產像這樣:
{!! asset_link('less/style.less') !!}
{!! asset_link('js/jquery.js') !!}
...甚至允許您自動編譯LESS樣式表,並會注意緩存。
在與OP進行對話時,在包含資產文件方面存在一些錯誤。 因此,應通過以下方式將它們包括在內:
<link type="text/css" href="{{URL::to('assets/plugins/pace/pace-theme-flash.css')}}"></link>
<link type="text/css" href="/assets/plugins/pace/pace-theme-flash.css"></link> \
圖片
<img alt="Cover photo" src="{{URL::to('assets/img/social/cover.png')}}" />
<img alt="Cover photo" src="/assets/img/social/cover.png" />
包含文件的方式很多,僅取決於您要遵循的文件。 檢查此鏈接是否也包含資產。 其余的laravel文檔始終都在那里。 :)
謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.