通常,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>