要在 livewire 裡面實現導到另一個頁面的功能,要使用 redirect() 的方法,比如我在下面設計這個 function:

public $target=1;
public function gotoPage(){
  return redirect()->to('/post?sn='.$this->target);
}

 

接著在前端我製作一個輸入框,可以依據使用者輸入的內容後按下 enter 就能跳到指定頁面:

<input type="text" wire:model="targetPage" wire:keyup.enter="gotoPage">