首页 > 解决方案 > 如何获取从laravel中的url收集的数据?

问题描述

我试图在刀片模板中使用 if 语句来显示和隐藏基于单击的选项卡的部分。如果我这样做['no' =>'1'],我会得到$name = 1。但如果我这样做 ['no' =>'{{no}}'],它什么也不会返回。我应该如何写才能$name = 1获得['no' =>'{{no}}']


网页.php

Route::get('/welcome/{no}', function () {
    return view('welcome',['no' =>'{{no}}']);
});

欢迎.blade.php

@if ($no == 1)
    @include('post.article')
@else
    @include('post.event')
@endif

标签: phplaravel-5laravel-routing

解决方案


你应该在你的路线中给出这样的:

Route::get('/welcome/{no}', function ($no) {
    return view('master/accesslog',['no' =>$no]);
});

这将被视为字符串'{{no}}'


推荐阅读