File tree Expand file tree Collapse file tree 1 file changed +3
-10
lines changed
src/content/docs/zh-cn/guides Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change @@ -173,22 +173,17 @@ import logoUrl from '../../assets/logo.png?url';
173173
174174你可以在 ` tsconfig.json ` 中添加导入别名。
175175
176- ``` json title="tsconfig.json" ins={5-6 }
176+ ``` json title="tsconfig.json" ins={4-5 }
177177{
178178 "compilerOptions" : {
179- "baseUrl" : " ." ,
180179 "paths" : {
181- "@components/*" : [" src/components/*" ],
182- "@assets/*" : [" src/assets/*" ]
180+ "@components/*" : [" ./ src/components/*" ],
181+ "@assets/*" : [" ./ src/assets/*" ]
183182 }
184183 }
185184}
186185```
187186
188- :::note
189- 确保 ` compilerOptions.baseUrl ` 已设置,以便可以解析别名路径。
190- :::
191-
192187在这个配置更改完之后,开发服务器会自动重启。然后,你可以在项目中的任何地方使用这些别名进行导入:
193188
194189``` astro title="src/pages/about/company.astro" ins="@components" ins="@assets"
@@ -198,8 +193,6 @@ import logoUrl from '@assets/logo.png?url';
198193---
199194```
200195
201- [ VS Code] ( https://code.visualstudio.com/docs/languages/jsconfig ) 或其他编辑器会自动集成这些别名。
202-
203196## ` import.meta.glob() `
204197
205198[ Vite 的 ` import.meta.glob() ` ] ( https://cn.vite.dev/guide/features.html#glob-import ) 是一种使用 glob 模式一次导入多个文件来查找匹配文件路径的方法。
You can’t perform that action at this time.
0 commit comments