我如何使用此路由输出到 h3 标签之间的索引页面

how do i use this route output to my index page between h3 tags

我的web.php

Route::get('/index',function()
{

    $count_total = DB::table('vendors')->count('id');

    return  $count_total;
}); 

在我的 index.blade.php

<h3>  </h3>

<p>Vendors</p>

试试这个...

Route::get('/', function () {
    return view('index', ['count_total' => $count_total]);
});

在index.blade.php

<h3> {{$count_total}} </h3>

<p>Vendors</p>

这样做

Route::get('/index',function()
{

    $count_total = DB::table('vendors')->count('id');

    return view('index',compact('count_total'));
}); 

然后在你的index.blade.php

<h3> {{$count_total}} </h3>

<p>Vendors</p>