最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

next.js - how to override parent layout header - Stack Overflow

programmeradmin0浏览0评论

I have folder structure as follows:

app
|_layout.tsx
|_feature1
  |_page.tsx
  |_layout.tsx
|_feature2
  |_page.tsx
... (other pages and folder that use main layout as-is)

app/layout:

<HTML><body>
<header>Root Header</header>
<body> {children} </body>
</body></html>

feature1/layout:

<header>Instead of Root, I should display</header>
{children}

Current output:

root header
Instead of Root, I should display

Question1: How can I override the header in feature1 layout to a different layout?

Question2: How can I hide header in feature 2?

Options, I thought of:

  1. A way that parent layout can read child layout overrides (like showHeader=false OR header = <replacementheader/>)
  2. Some declarative way in child layouts that override parent layout (I did it once long back but fot how I did
发布评论

评论列表(0)

  1. 暂无评论