$app/stores
此模块包含了对从 $app/state 导出的基于存储的等效项。如果您正在使用 SvelteKit 2.12 或更高版本,请使用该模块。
import { function getStores(): {
page: typeof page;
navigating: typeof navigating;
updated: typeof updated;
}
getStores, const navigating: Readable<Navigation | null>A readable store.
When navigating starts, its value is a Navigation object with from, to, type and (if type === 'popstate') delta properties.
When navigating finishes, its value reverts to null.
On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.
navigating, const page: Readable<Page<Record<string, string>, string | null>>A readable store whose value contains page data.
On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.
page, const updated: Readable<boolean> & {
check(): Promise<boolean>;
}
A readable store whose initial value is false. If version.pollInterval is a non-zero value, SvelteKit will poll for new versions of the app and update the store value to true when it detects one. updated.check() will force an immediate check, regardless of polling.
On the server, this store can only be subscribed to during component initialization. In the browser, it can be subscribed to at any time.
updated } from '$app/stores';获取商店
function getStores(): {
page: typeof page;
navigating: typeof navigating;
updated: typeof updated;
};导航
使用从
$app/state的navigating替代(需要 Svelte 5,查看文档以获取更多信息)
可读的存储。当开始导航时,其值是一个具有 Navigation 对象,包含 from、to、type 和(如果 type === 'popstate')delta 属性的 null。当导航完成时,其值恢复为 null。
在服务器上,此存储只能在组件初始化期间订阅。在浏览器中,可以在任何时候订阅。
const navigating: import('svelte/store').Readable<
import('@sveltejs/kit').Navigation | null
>;页
使用
页面从$app/state中代替(需要 Svelte 5,查看文档获取更多信息)
一个包含页面数据的可读存储。
在服务器上,此存储只能在组件初始化期间订阅。在浏览器中,可以在任何时候订阅。
const page: import('svelte/store').Readable<
import('@sveltejs/kit').Page
>;更新
使用
updated从$app/state中替换(需要 Svelte 5,查看文档获取更多信息)
一个初始值为false的可读存储。如果version.pollInterval是一个非零值,SvelteKit 将轮询应用的新版本,并在检测到新版本时将存储值更新为true。updated.check()将强制立即检查,无论是否轮询。
在服务器上,此存储只能在组件初始化期间订阅。在浏览器中,可以在任何时候订阅。
const updated: import('svelte/store').Readable<boolean> & {
check(): Promise<boolean>;
};Edit this page on GitHub llms.txt