"NetworkError: 404 Not Found in laravel 5.1
"NetworkError: 404 Not Found in laravel 5.1
当我点击 link 时,我获得了数据,但我的 css 页面、Js 文件和图像无法正常工作。下面我提到 link、路由、控制器和错误(Firebug 控制台)。请帮助我清除此错误。
Link 来自页面
<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"
Link 到 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')!!}
Link 到 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 都在 public 文件夹中
看起来你对资产使用了相对 links(比如 <a href="somelink"><img src="assets/img/demo/calendar_app.svg">Link</a>
),而绝对 links 应该被使用:
<a href="somelink"><img src="/assets/img/demo/calendar_app.svg">Link</a>
或者,以更 Laravel 的方式:
<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')!!}
links 修复为绝对 links,或使用 SerafimArts/Asset 包,它将允许您 link 页面上的资产这个:
{!! 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" />
包含文件的方法有很多种,就看你遵循哪一种了。 check this link 也包括资产。其余 laravel 文档始终存在。 :)
谢谢
当我点击 link 时,我获得了数据,但我的 css 页面、Js 文件和图像无法正常工作。下面我提到 link、路由、控制器和错误(Firebug 控制台)。请帮助我清除此错误。
Link 来自页面
<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"
Link 到 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')!!}
Link 到 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 都在 public 文件夹中
看起来你对资产使用了相对 links(比如 <a href="somelink"><img src="assets/img/demo/calendar_app.svg">Link</a>
),而绝对 links 应该被使用:
<a href="somelink"><img src="/assets/img/demo/calendar_app.svg">Link</a>
或者,以更 Laravel 的方式:
<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')!!}
links 修复为绝对 links,或使用 SerafimArts/Asset 包,它将允许您 link 页面上的资产这个:
{!! 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" />
包含文件的方法有很多种,就看你遵循哪一种了。 check this link 也包括资产。其余 laravel 文档始终存在。 :)
谢谢