diff --git a/src/content/docs/zh-cn/guides/images.mdx b/src/content/docs/zh-cn/guides/images.mdx index 1f7baa4a6dfb8..a528cfa45b16b 100644 --- a/src/content/docs/zh-cn/guides/images.mdx +++ b/src/content/docs/zh-cn/guides/images.mdx @@ -432,6 +432,33 @@ import Logo from '../assets/logo.svg'; ``` +#### `SvgComponent` 类型 + + + +你也可以使用 `SvgComponent` 类型对 `.svg` 资源强制实施类型安全: + +```astro title="src/components/Logo.astro" +--- +import type { SvgComponent } from "astro/types"; +import HomeIcon from './Home.svg' + +interface Link { + url: string + text: string + icon: SvgComponent +} + +const links: Link[] = [ + { + url: '/', + text: 'Home', + icon: HomeIcon + } +] +--- +``` + ### 创建自定义图像组件 你可以通过将 `` 或 `` 组件包装在另一个 Astro 组件中来创建自定义、可重用的图像组件。这允许你只设置一次默认属性和样式。