如何在laravel livewire中显示博客文章?

时间:2020-11-01 05:42:49

标签: php laravel laravel-livewire

我正在使用Laravel Livewire,并且只能显示博客中的单个帖子。 我做了一些事情,但没有显示该帖子。

这是路线:

Route::get('/blog', function () {
    return view('pages/blog');
})->name('/blog');
Route::get('/blog/{id}', ShowPost::class)->name('/blog.show');

这是ShowPost组件:

<?php

namespace App\Http\Livewire\Blog;

use App\Models\Blog;
use Livewire\Component;
    
class ShowPost extends Component
{
    public $post;
    public $local;
    
    public function mount($id) 
    {
        $this->local = app()->getLocale();
        $this->post = Blog::find($id);
    }
        
    public function render()
    {
        return view('livewire.blog.show-post')
            ->extends('pages.layout')
            ->section('content')
            ->section('local', '{{$local}}');
    }
}

这是错误:

缺少[Route:/blog.show] [URI:{language} / blog / {id}]所需的参数。 (查看:C:\ xampp \ htdocs \ Hikeventure \ resources \ views \ livewire \ navbars.blade.php)(查看:C:\ xampp \ htdocs \ Hikeventure \ resources \ reviews \ livewire \ navbars.blade.php)(查看:C:\ xampp \ htdocs \ Hikeventure \ resources \ views \ livewire \ navbars.blade.php)

0 个答案:

没有答案