为什么 laravel 不显示 blade?

why is laravel not displaying the blade?

我目前正在学习有关 laravel 的 websocket 的教程。 我完全喜欢这个教程,但是...... 这是代码 控制器:

class CommentController extends Controller{
public function getcomments(Post $post){
    return response()->json($post->comments()->with('user')->latest()->get());

}
public function addcomment(Request $req,Post $post){
   $comment=$post->comment()->create([
       'body'=>$req->body,
       'user_id'=>auth::id()
   ]);
   $comment=Comment::where('id',$comment->id)->with('user')->first();
    return $comment->toJson;
}}

routes/api 文件

Route::get('/post/{post}', 'CommentController@getcomments');
Route::middleware('auth:api')->group(function () {
      Route::post('/post/{post}', 'CommentController@addcomment');});

在教程中,当他转到 /post/1 时,它会在 post.blade.php

中显示 html 代码

这是我从中得到的 enter image description here

请帮助:)

可能您的教程视频要求您访问 /post/1,但 /api/post/1 是您所做的。 API 可能用于获取位于 /post/1.

的 post 和 id:1 的所有评论