Skip to main content

$app/stores

此模块包含从 $app/state 导出的基于 store 的等价物。如果您使用的是 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.

@deprecatedUse navigating from $app/state instead (requires Svelte 5, see docs for more info)
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.

@deprecatedUse page from $app/state instead (requires Svelte 5, see docs for more info)
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.

@deprecatedUse updated from $app/state instead (requires Svelte 5, see docs for more info)
updated
} from '$app/stores';

getStores

function getStores(): {
	page: typeof page;

	navigating: typeof navigating;

	updated: typeof updated;
};

导航

请改用 $app/state 中的 navigating(需要 Svelte 5,查看更多信息

一个可读 store。当导航开始时,其值为一个具有 fromtotype 和(如果 type === 'popstate'delta 属性的 Navigation 对象。当导航结束时,其值恢复为 null

在服务端上,此 store 只能在组件初始化期间被订阅。在浏览器中,它可以在任何时候被订阅。

const navigating: import('svelte/store').Readable<
	import('@sveltejs/kit').Navigation | null
>;

page

请改用 $app/state 中的 page(需要 Svelte 5,查看更多信息

一个可读 store ,其值包含页面数据。

在服务端上,此 store 只能在组件初始化期间被订阅。在浏览器中,它可以在任何时候被订阅。

const page: import('svelte/store').Readable<
	import('@sveltejs/kit').Page
>;

updated

请改用 $app/state 中的 updated(需要 Svelte 5,查看更多信息

一个可读 store ,其初始值为 false。如果 version.pollInterval 为非零值,SvelteKit 将轮询应用程序的新版本,并在检测到新版本时将 store 值更新为 true。无论是否轮询,updated.check() 都将强制立即检查。

在服务端上,此 store 只能在组件初始化期间被订阅。在浏览器中,它可以在任何时候被订阅。

const updated: import('svelte/store').Readable<boolean> & {
	check(): Promise<boolean>;
};

在 GitHub 编辑此页面

上一页 下一页