【问题标题】:How do I get data from the Route and show it in a html page?如何从 Route 获取数据并将其显示在 html 页面中?
【发布时间】:2021-05-07 22:13:03
【问题描述】:

我正在尝试从 URL 获取值,例如:websitename.com/dash/namehere

我有路线:

Route::get('/dash/{id}', 'DashController@index' , function($id) {

    return 'dash'.$id;
}); 

然后,我在尝试显示为标题的页面上有一个部分。我目前正在使用这个:

@if (\Request::is('dash/1'))  
<div class="pagetitle">[clientname]</div>
@endif

这可行,但我认为有更好的方法来解决这个问题。我对此很陌生。 我想从 url /site.com/dash/ {id} 获取 id 并在 HTML 页面中将其用作 Title 标题。

【问题讨论】:

    标签: laravel laravel-routing


    【解决方案1】:

    在你的刀片中使用{{ request()-&gt;route('id') }} 从短跑路线中获取“id”参数。

    【讨论】:

      猜你喜欢
      • 2020-07-27
      • 1970-01-01
      • 1970-01-01
      • 2021-10-31
      • 2021-05-03
      • 2013-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多