Skip to main content
基本 Svelte
介绍
反应性
属性
逻辑
事件
绑定
类和样式
动作
转换
高级 Svelte
高级反应性
重用内容
运动
高级绑定
高级转换
上下文 API
特殊元素
<script module>
后续步骤
基本 SvelteKit
介绍
路由
加载数据
标题和 cookie
共享模块
表单
API 路由
$app/state
错误和重定向
高级 SvelteKit
钩子
页面选项
链接选项
高级路由
高级加载
环境变量
结论

通常,SvelteKit 会在页面之间导航而不刷新页面。在此练习中,如果我们在 //about 之间导航,计时器会继续滴答作响。

¥Ordinarily, SvelteKit will navigate between pages without refreshing the page. In this exercise, if we navigate between / and /about, the timer keeps on ticking.

在极少数情况下,你可能想要禁用此行为。你可以通过在单个链接或任何包含链接的元素上添加 data-sveltekit-reload 属性来实现此目的:

¥In rare cases, you might want to disable this behaviour. You can do so by adding the data-sveltekit-reload attribute on an individual link, or any element that contains links:

src/routes/+layout
<nav data-sveltekit-reload>
	<a href="/">home</a>
	<a href="/about">about</a>
</nav>

有关可用链接选项及其值的更多信息,请参阅 链接选项文档

¥For more information on available link options and their values, consult the link options documentation.

上一页 下一页
1
2
3
<h1>home</h1>
<p>this is the home page.</p>