當我點擊注冊頁面時,我的專案回傳了這個煩人的 404 錯誤。不知道可能是什么。我的帶有登錄表單的主頁,下面是這個:
<script>
import supabase from "$lib/external/supa";
import { goto } from "$app/navigation";
let email = "";
let password = "";
export let title;
async function handleLogin() {
if (title == "Login") {
const { user, error } = await supabase.auth.signIn({
email: email,
password: password,
});
if (user) {
goto("/dashboard");
} else {
console.log(error);
}
} else {
const { user, error } = await supabase.auth.signUp({
email: email,
password: password,
});
if (user) {
goto("/dashboard");
} else {
console.log(error);
}
}
}
</script>
<div class="loginFormContainer">
<h1>{title}</h1>
<form class="loginForm" on:submit|preventDefault={handleLogin}>
<input type="email" bind:value={email} placeholder="[email protected]"/>
<input type="password" bind:value={password} placeholder="password"/>
<button type="submit">{title}</button>
</form>
<a href="/signup">Not a member? Sign up</a>
</div>
當我單擊注冊按鈕時,出現以下錯誤:
404
Not found: /signup
Error: Not found: /signup
at resolve (file:///<path>/node_modules/@sveltejs/kit/src/runtime/server/index.js:326:13)
at Object.handle (file:///<path>/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:319:66)
at respond (file:///<path>/node_modules/@sveltejs/kit/src/runtime/server/index.js:345:30)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async file:///<path>/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:385:22
而這個我的signup.svelte
<script>
import LoginForm from "$lib/components/loginForm.svelte";
</script>
<div class="container">
<LoginForm title="Sign Up" />
</div>
我不是 Svelte 或前端開發方面的專家,但我認為這可能與路線有關,當我檢查頁面時,我剛剛得到
Failed to load resource: the server responded with a status of 404 (Not Found)
我用這個視頻作為參考:

謝謝!
uj5u.com熱心網友回復:
路由系統在最近的版本中發生了變化,現在您必須為每個路由創建一個檔案夾,因此您的檔案夾結構必須是:
/src
/routes
/dashboard
page.svelte
/signup
page.svelte
page.svelte
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/506664.html
