简体   繁体   English

“在Laravel 5.1中找不到NetworkError:404

[英]"NetworkError: 404 Not Found in laravel 5.1

When I click on a link I have getting the data but my css pages, Js files and images are not working. 当我单击一个链接时,我已经得到了数据,但是我的css页面,Js文件和图像不起作用。 Below I mention the link, route, controller and error(Firebug console). 下面我提到链接,路由,控制器和错误(Firebug控制台)。 Please help me to clear this error. 请帮助我清除此错误。

Link from a page 页面链接

<a href="customersocialpage/<?php echo $searchCustomer->customer_id; ?>"><?php echo ucfirst($searchCustomer->firstname); ?></span> <?php echo ucfirst($searchCustomer->lastname); ?></h5></a>

routes.php routes.php

$router->get('customersocialpage/{id}', ['as' => 'custsocialpage', 'uses' => 'CustomersocialpageController@index']);

CustomersocialpageController.php CustomersocialpageController.php

public function index($id)
    {
        dd($id);
        $customersocialpages = Customeraddress::where('customer_id', $id)->first();
        return view('pages.customersocialpage',['customersocialpages' => $customersocialpages]);
    }

Error 错误

"NetworkError: 404 Not Found - http://baselaravel.dev/customersocialpage/assets/img/demo/calendar_app.svg"

Link to CSS 链接到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 to JS 链接到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')!!}

All the css, images and js are in public folder 所有的css,图片和js都位于公用文件夹中

Looks like you used relative links to assets (like <a href="somelink"><img src="assets/img/demo/calendar_app.svg">Link</a> ), when absolute links meant to be used: 当您使用绝对链接时,您似乎使用了到资产的相对链接(例如<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>

or, in more Laravel'ish way: 或者,以更Laravel'ish的方式:

<a href="{{ route('customersocialpage.index', $searchCustomer->customer_id) }}"><img src="{{ asset('assets/img/demo/calendar_app.svg') }}">Link</a>

Upd. 更新。

Fix yours {!!HTML::style('assets/plugins/pace/pace-theme-flash.css')!!} links to absolute links, or use SerafimArts/Asset package, it will allow you to link assets on page like this: 修正您的{!!HTML::style('assets/plugins/pace/pace-theme-flash.css')!!}链接到绝对链接,或使用SerafimArts / Asset包,它将允许您链接页面上的资产像这样:

{!! asset_link('less/style.less') !!}
{!! asset_link('js/jquery.js') !!}

...and even allow you to automatically compile LESS stylesheets and will take care about caching. ...甚至允许您自动编译LESS样式表,并会注意缓存。

Ok as conversation with the OP ,there were some mistakes in including assets file . 在与OP进行对话时,在包含资产文件方面存在一些错误。 So they should be included in following ways : 因此,应通过以下方式将它们包括在内:

<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> \

Images 图片

 <img alt="Cover photo" src="{{URL::to('assets/img/social/cover.png')}}" />

 <img alt="Cover photo" src="/assets/img/social/cover.png" />

There are many ways of including files , just depend on you which you follow . 包含文件的方式很多,仅取决于您要遵循的文件。 check this link for including assets also . 检查此链接是否也包含资产。 Rest laravel docs are always there. 其余的laravel文档始终都在那里。 :) :)

Thanks 谢谢

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

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