跳至內容

頁面

頁面是路由獨有的 UI。您可以透過從 page.js 檔案預設匯出一個組件來定義頁面。

例如,要建立您的 index 頁面,請在 app 目錄內新增 page.js 檔案

page.js special file
app/page.tsx
// `app/page.tsx` is the UI for the `/` URL
export default function Page() {
  return <h1>Hello, Home page!</h1>
}

然後,要建立更多頁面,請建立一個新資料夾並在其中新增 page.js 檔案。例如,要為 /dashboard 路由建立一個頁面,請建立一個名為 dashboard 的新資料夾,並在其中新增 page.js 檔案

app/dashboard/page.tsx
// `app/dashboard/page.tsx` is the UI for the `/dashboard` URL
export default function Page() {
  return <h1>Hello, Dashboard Page!</h1>
}

注意事項: