Skip to main content
Svelte基础
介绍
响应
属性Props
逻辑表达式
事件
绑定
Classes和样式
动作Actions
Transitions
Advanced Svelte
Advanced reactivity
Reusing content
Motion
Advanced bindings
Advanced transitions
Context API
Special elements
<script module>
Next steps
Basic SvelteKit
Introduction
Routing
Loading data
Headers and cookies
Shared modules
Forms
API routes
$app/state
Errors and redirects
Advanced SvelteKit
Hooks
Page options
Link options
Advanced routing
Advanced loading
Environment variables
Conclusion

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

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.

Let’s reset it all the way to the root layout, by renaming it to +page@.svelte.

The root layout applies to every page of your app, you cannot break out of it.

Edit this page on GitHub

1
2
<h1>home</h1>