accessing public folder in laravel using blade

2019-09-14 17:47发布

I have a view called homePage.blade.php which is my master page which resides in res/views/ in that file I have this.

<link rel="stylesheet" href="css/coreStyleSheet.css">
<link rel="stylesheet" href="css/animate.css">
<script src="js/coreScripting.js"></script>
<script src="js/moments.js"></script>
<link rel="stylesheet" href="icons/fontAwesome/css/font-awesome.css"> </head>

all is fine?

Now I create a folder called AppCreate who's path is res/views/AppCreate I have a blade file there called something.blade.php now when I use @extends('homePage') I am not able to access the css,js.

my tree looks like this.

-res -views homePage.blade.php -AppCreate -something.blade.php

I redirect something.blade.php tp public/admin/appcreate I redirect homePage.blade.php to public/dashBoard.

I hope I have explained it well.

when I access the public /admin/appcreate laravel is not able to find the css and the js because it says this.

    GET http://localhost/laravel/public/admin/css/coreStyleSheet.css 
appcreate:12 GET http://localhost/laravel/public/admin/js/moments.js 
appcreate:11 GET http://localhost/laravel/public/admin/js/coreScripting.js 
appcreate:13 GET http://localhost/laravel/public/admin/icons/fontAwesome/css/font-awesome.css 

1条回答
Juvenile、少年°
2楼-- · 2019-09-14 17:53

Try using the Helper Functions like this:

<link rel="stylesheet" href="{{ asset('css/animate.css') }}">

<script src="{{ asset('js/coreScripting.js') }}"></script>

assuming you have your css and js folders inside public/assets

查看更多
登录 后发表回答