“NetworkError:在laravel 5.1中找不到404

When I click on a link I have getting the data but my css pages, Js files and images are not working. Below I mention the link, route, controller and error(Firebug console). 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

$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]);
    }

Error

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

Link to 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

{!!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

doushi8231
doushi8231 让我们在聊天中继续讨论。
接近 5 年之前 回复
donglefu6195
donglefu6195 显示“NetworkError:404NotFound-baselaravel.dev/customersocialpage/assets/img/logo_white.png”
接近 5 年之前 回复
dqu92800
dqu92800 baselaravel.dev/customersocialpage/assets/img/demo/...url看起来不太好。baselaravel.dev是你的域名,然后url应该是baselaravel.dev/assets/img/demo/calendar_app.svg。对?
接近 5 年之前 回复
dongqiangse6623
dongqiangse6623 是的,确定。我更新了我的问题
接近 5 年之前 回复
du90093662774150
du90093662774150 你能告诉你如何将它们包含在你的html文件中吗?
接近 5 年之前 回复
douna2633
douna2633 是的css,js,图像都在公共文件夹中。
接近 5 年之前 回复
doushan5245
doushan5245 这看起来令人困惑。css,js,assets文件夹是否位于公用文件夹中?
接近 5 年之前 回复
doutan2228
doutan2228 您需要公开提供“静态”文件(样式,图像,javascript),因此您应该将它们保存在项目的公共文件夹中。看看这篇文章,可能会有所帮助:stackoverflow.com/questions/28496301/...
接近 5 年之前 回复

2个回答

Ok as conversation with the OP ,there were some mistakes in including assets file . 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. :)

Thanks

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>

or, in more Laravel'ish way:

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

{!! 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.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问