通常,页面会继承其上方的每个布局,这意味着 src/routes/a/b/c/+page.svelte
继承了四个布局:
¥Ordinarily, a page inherits every layout above it, meaning that src/routes/a/b/c/+page.svelte
inherits four layouts:
src/routes/+layout.svelte
src/routes/a/+layout.svelte
src/routes/a/b/+layout.svelte
src/routes/a/b/c/+layout.svelte
有时,打破当前布局层次结构很有用。我们可以通过将 @
符号后跟父段的名称添加到 ‘reset’ 来实现这一点 — 例如,+page@b.svelte
会将 /a/b/c
放在 src/routes/a/b/+layout.svelte
内,而 +page@a.svelte
会将其放在 src/routes/a/+layout.svelte
内。
¥Occasionally, it’s useful to break out of the current layout hierarchy. We can do that by adding the @
sign followed by the name of the parent segment to ‘reset’ to — for example +page@b.svelte
would put /a/b/c
inside src/routes/a/b/+layout.svelte
, while +page@a.svelte
would put it inside src/routes/a/+layout.svelte
.
让我们将其重置为根布局,将其重命名为 +page@.svelte
。
¥Let’s reset it all the way to the root layout, by renaming it to +page@.svelte
.
根布局适用于应用的每个页面,你无法脱离它。
¥[!NOTE] The root layout applies to every page of your app, you cannot break out of it.
<h1>home</h1>