【问题标题】:How to check Request::is('/new/*') in Blade view in Laravel 6如何在 Laravel 6 的 Blade 视图中检查 Request::is('/new/*')
【发布时间】:2020-04-16 23:41:33
【问题描述】:

如何在 Laravel 6 的 Blade 视图中检查 Request::is('/new/*')?我的主页上没有侧边栏。但是,我想要 domain.com/new/x 页面上的侧边栏,例如 domain.com/new/231

这就是我所做的,但它不起作用。

@if(Request::is('/new/*'))
    @include('inc.sidebar')
@endif

【问题讨论】:

    标签: laravel view laravel-blade laravel-6


    【解决方案1】:

    您是否尝试匹配路由或 URL?你能在 web.php 中显示你的路线吗?

    @if (\Request::is('new/*')) { 
        // will match URL /new/231 or /new/x
    @endif
    

    【讨论】:

    • Route::get('/new/{newId}', 'PostController@display'); class PostController extends Controller { ` //单页显示` ` public function display($id){` ` return view('post');` ` }` }
    猜你喜欢
    • 2016-05-13
    • 2021-02-11
    • 2018-06-10
    • 2018-09-23
    • 2016-06-21
    • 2020-04-19
    • 1970-01-01
    • 2020-08-27
    • 2020-03-31
    相关资源
    最近更新 更多