跳至主要內容

$app/stores

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;
};

一個可讀取的 store。當導航開始時,其值為一個具有 fromtotype 和(如果 type === 'popstate'delta 屬性的 Navigation 物件。當導航結束時,其值會還原為 null

在伺服器上,這個 store 只能在元件初始化期間訂閱。在瀏覽器中,可以隨時訂閱。

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

page

一個可讀取的 store,其值包含頁面資料。

在伺服器上,這個 store 只能在元件初始化期間訂閱。在瀏覽器中,可以隨時訂閱。

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

updated

一個可讀取的 store,其初始值為 false。如果 version.pollInterval 是一個非零值,SvelteKit 會輪詢應用程式的新版本,並在偵測到新版本時將 store 的值更新為 trueupdated.check() 會強制立即檢查,無論是否輪詢。

在伺服器上,這個 store 只能在元件初始化期間訂閱。在瀏覽器中,可以隨時訂閱。

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

在 GitHub 上編輯此頁面

上一頁 下一頁