wer*_*rhw 8 typescript nuxt.js vuejs3 nuxt3
我有一些类型想要在我的 nuxt 3 应用程序中自动导入,但是每次我尝试导出包含类型的 ts 文件时,它都会以某种方式跳过或忽略这些类型。我找到了一种将它们全局导入到所有打字稿文件的方法,但我希望它们也位于 .vue 文件中。
我有这个文件和我的类型。
useType.ts
export type ImageDocument = {
buildId: string
links: string[]
}
export type InventoryDocument = {
buildId: string
block: string
count: number
}
Run Code Online (Sandbox Code Playgroud)
该文件位于 /utils 文件夹中。我还尝试将其移至可组合项文件夹,但没有任何区别。
小智 4
您需要在 nuxt.config.ts 中声明您的文件夹类型的自动导入文件夹:
imports: {
dirs: ['types/*.ts', 'store/*.ts', 'types/**/*.ts'],
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2484 次 |
| 最近记录: |