我用過-
route::get(& quot;/product-detail/{ slug } & quot;,App \ Http \ live wire \ ProductDetailComponent::class)-& gt;名稱(& quot產品詳細信息& quot);
在網絡路線中。
此外,我正在使用- {{route('產品詳細信息',[' slug ' = & gt;$ product-& gt;slug])}} 在“我的shop-component.blade.php”中,訪問產品頁面。
namespace App\Http\Livewire;
use Livewire\Component;
use App\Models\Product;
class ProductDetailComponent extends Component
{
public $p_slug;
public function mount($slug)
{
$this->p_slug=$slug;
}
public function render()
{
$product=Product::where('slug',$this->p_slug)->first();
return view('livewire.product-detail-component',['product'=>$product])->layout("layouts.base");
}
}
this is what I have used in my ProductDetailComponent.php file