clearError

原始檔
clearError 可組合函式清除所有已處理的錯誤。

在你的頁面、元件和外掛中,你可以使用 clearError 來清除所有錯誤並重定向使用者。

引數

  • options?: { redirect?: string }

你可以提供一個可選的路徑進行重定向(例如,如果你想導航到一個“安全”頁面)。

// Without redirect
clearError()

// With redirect
clearError({ redirect: '/homepage' })

錯誤透過 useError() 設定在狀態中。clearError 可組合函式將重置此狀態並使用提供的選項呼叫 app:error:cleared 鉤子。

閱讀更多內容請參見 文件 > 4 X > 入門 > 錯誤處理