ๅธๅฑ๏ผLayout๏ผ
ๅจๅฎ็ฐ่ทฏ็ฑๆถ๏ผไธๅ็่ทฏ็ฑ้ๅธธๅ ฑไบซไธไธชๅ ฑๅ็้กต็ใ้กต่ๅ่ๅ็ณป็ปใๆไปฌ็งฐๅ ฌๅ ฑ้จๅไธบๅธๅฑ๏ผlayout๏ผใ
ๅผๅไบบๅๅฏไปฅๅฐๆๆ่ฟไบๆๅๅฐ <Header>
ใ<Footer>
ๅ <Menu>
็ปไปถไธญ๏ผๅนถๆๅจๅฐๅฎไปฌๆทปๅ ๅฐๆฏไธช้กต้ข็ปไปถไธญ๏ผไฝ่ฟๆฏ้ๅคไธๅฎนๆๅบ้็ใ
็ธๅ๏ผๆไปฌๅฏไปฅไฝฟ็จๅธๅฑ๏ผLayout๏ผๆฅ่ชๅจ้็จๅ
ฌๅ
ฑ้จๅใ
ไพๅญ
ๅ่ฎพๆไปฌๅธๆๆไปฌ็็ฝ็ซ็่ตทๆฅๅ่ฟๆ ท๏ผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Header โ
โโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Menu โ <ROUTE_SPECIFIC_CONTENT> โ
โ - home โ โ
โ - about โ โ
โ โ โ
โโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Footer โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
ๆไปฌๅฏไปฅ็จ่ฟไบๆไปถๅฎไนไธ่ฟฐๅ ๅฎน๏ผ
src/
โโโ components/
โ โโโ header.tsx # Header component implementation
โ โโโ footer.tsx # Footer component implementation
โ โโโ menu.tsx # Menu component implementation
โโโ routes/
โโโ layout.tsx # Layout implementation using: <Header>, <Footer>, and <Menu>
โโโ about/
โ โโโ index.tsx # https://example.com/about
โโโ index.tsx # https://example.com
็ปไปถๅฎ็ฐ
// File: src/components/header.tsx
export default component$(() => {
return <>Header</>;
});
// File: src/components/footer.tsx
export default component$(() => {
return <>Footer</>;
});
// File: src/components/menu.tsx
export default component$(() => {
return (
<ul>
<li>home</li>
<li>about</li>
</ul>
);
});
// File: src/routes/layout.tsx
export default component$(() => {
return (
<>
<Header />
<Menu />
<Slot/> {/* <== This is where the route will be inserted */}
<Footer />
</>
);
});
// File: src/routes/index.tsx
export default component$(() => {
return <>Home</>;
});
// File: src/routes/about/index.tsx
export default component$(() => {
return <>About</>;
});