使用 blade 访问 laravel 中的 public 文件夹
accessing public folder in laravel using blade
我有一个名为 homePage.blade.php
的视图,它是我的母版页,位于该文件的 res/views/
中,我有这个。
<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>
一切都好吗?
现在我创建了一个名为 AppCreate
的文件夹,其路径为 res/views/AppCreate
我有一个名为 something.blade.php
的 blade 文件,现在当我使用 @extends('homePage')
我我无法访问 css,js。
我的树看起来像这样。
-res
-观点
homePage.blade.php
-AppCreate
-something.blade.php
我重定向 something.blade.php tp public/admin/appcreate
我将 homePage.blade.php 重定向到 public/dashBoard.
希望我已经解释清楚了。
当我访问 public /admin/appcreate laravel 时找不到 css 和 js,因为它说了这个。
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
尝试像这样使用 Helper Functions:
<link rel="stylesheet" href="{{ asset('css/animate.css') }}">
<script src="{{ asset('js/coreScripting.js') }}"></script>
假设您的 css 和 js 文件夹位于 public/assets
我有一个名为 homePage.blade.php
的视图,它是我的母版页,位于该文件的 res/views/
中,我有这个。
<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>
一切都好吗?
现在我创建了一个名为 AppCreate
的文件夹,其路径为 res/views/AppCreate
我有一个名为 something.blade.php
的 blade 文件,现在当我使用 @extends('homePage')
我我无法访问 css,js。
我的树看起来像这样。
-res -观点 homePage.blade.php -AppCreate -something.blade.php
我重定向 something.blade.php tp public/admin/appcreate 我将 homePage.blade.php 重定向到 public/dashBoard.
希望我已经解释清楚了。
当我访问 public /admin/appcreate laravel 时找不到 css 和 js,因为它说了这个。
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
尝试像这样使用 Helper Functions:
<link rel="stylesheet" href="{{ asset('css/animate.css') }}">
<script src="{{ asset('js/coreScripting.js') }}"></script>
假设您的 css 和 js 文件夹位于 public/assets