$app/stores
此模块包含 $app/state
导出的基于存储的等效项。如果你使用的是 SvelteKit 2.12 或更高版本,请改用该模块。
¥This module contains store-based equivalents of the exports from $app/state
. If you’re using SvelteKit 2.12 or later, use that module instead.
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';
getStores
function getStores(): {
page: typeof page;
navigating: typeof navigating;
updated: typeof updated;
};
navigating
改用
$app/state
中的navigating
(需要 Svelte 5、查看文档了解更多信息)¥Use
navigating
from$app/state
instead (requires Svelte 5, see docs for more info)
可读存储。导航开始时,其值是具有 from
、to
、type
和(如果是 type === 'popstate'
)delta
属性的 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.
const navigating: import('svelte/store').Readable<
import('@sveltejs/kit').Navigation | null
>;
page
改用
$app/state
中的page
(需要 Svelte 5、查看文档了解更多信息)¥Use
page
from$app/state
instead (requires Svelte 5, see docs for more info)
值包含页面数据的可读存储。
¥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.
const page: import('svelte/store').Readable<
import('@sveltejs/kit').Page
>;
updated
改用
$app/state
中的updated
(需要 Svelte 5、查看文档了解更多信息)¥Use
updated
from$app/state
instead (requires Svelte 5, see docs for more info)
初始值为 false
的可读存储。如果 version.pollInterval
是非零值,SvelteKit 将轮询应用的新版本,并在检测到新版本时将存储值更新为 true
。updated.check()
将强制立即检查,无论轮询如何。
¥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.
const updated: import('svelte/store').Readable<boolean> & {
check(): Promise<boolean>;
};