如何从路线获取数据并将其显示在 html 页面中?

How do I get data from the Route and show it in a html page?

我正在尝试从 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 页面中将其用作标题 header.

在你的 blade 中使用 {{ request()->route('id') }} 从 dash 路由获取“id”参数。