Skip to main content

$app/paths

import { let assets: "" | `https://${string}` | `http://${string}` | "/_svelte_kit_assets"

An absolute path that matches config.kit.paths.assets.

If a value for config.kit.paths.assets is specified, it will be replaced with '/_svelte_kit_assets' during vite dev or vite preview, since the assets don’t yet live at their eventual URL.

assets
, let base: "" | `/${string}`

A string that matches config.kit.paths.base.

Example usage: <a href="{base}/your-page">Link</a>

base
, function resolveRoute(id: string, params: Record<string, string | undefined>): string

Populate a route ID with params to resolve a pathname.

@examplejs import { resolveRoute } from '$app/paths'; resolveRoute( `/blog/[slug]/[...somethingElse]`, { slug: 'hello-world', somethingElse: 'something/else' } ); // `/blog/hello-world/something/else`
resolveRoute
} from '$app/paths';

资产

绝对路径匹配 config.kit.paths.assets

[注意] 如果指定了 config.kit.paths.assets 的值,则在 vite devvite preview 期间,它将被 '/_svelte_kit_assets' 替换,因为资产尚未位于其最终 URL。

let assets:
	| ''
	| `https://${string}`
	| `http://${string}`
	| '/_svelte_kit_assets';

基础

一个匹配config.kit.paths.base的字符串。

示例用法: <a href="{base}/your-page">Link</a>

let base: '' | `/${字符串}`;

解决路由

填充路由 ID 以解析路径名。

import { function resolveRoute(id: string, params: Record<string, string | undefined>): string

Populate a route ID with params to resolve a pathname.

@examplejs import { resolveRoute } from '$app/paths'; resolveRoute( `/blog/[slug]/[...somethingElse]`, { slug: 'hello-world', somethingElse: 'something/else' } ); // `/blog/hello-world/something/else`
resolveRoute
} from '$app/paths';
function resolveRoute(id: string, params: Record<string, string | undefined>): string

Populate a route ID with params to resolve a pathname.

@examplejs import { resolveRoute } from '$app/paths'; resolveRoute( `/blog/[slug]/[...somethingElse]`, { slug: 'hello-world', somethingElse: 'something/else' } ); // `/blog/hello-world/something/else`
resolveRoute
(
`/blog/[slug]/[...somethingElse]`, { slug: stringslug: 'hello-world', somethingElse: stringsomethingElse: 'something/else' } ); // `/blog/hello-world/something/else`
function resolveRoute(
	id: string,
	params: Record<string, string | undefined>
): string;

Edit this page on GitHub llms.txt