Skip to main content
Svelte基础
介绍
响应
属性Props
逻辑表达式
事件
绑定
Classes和样式
动作Actions
转场
Svelte高阶
响应式进阶
内容复用
动画
高级绑定
高级转场
上下文API
特殊元素
脚本模块
接下来
SvelteKit基础
介绍
路由
加载数据
Headers和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>