vue3 使用ts 报错,找不到模块问题配置
vue3 使用ts 报错,找不到模块问题配置:
cannot find module '../views/aboutview.vue'
1.env.d.ts
2.tsconfig.app.json
1.env.d.ts
interface ImportMetaEnv {
readonly VITE_API_BASE_URL: string
readonly VITE_API_BASE_PORT: string
readonly VITE_APP_TITLE: string
readonly VITE_APP_ENV: 'development' | 'test' | 'production'
readonly VITE_APP_API_TIMEOUT: string
readonly VITE_USE_DEVTOOLS: string
readonly VITE_USE_PROXY: string
readonly VITE_PROXY_URL: string
readonly VITE_DROP_CONSOLE_DEBUGGER: string
}
interface ImportMeta {
readonly env: ImportMetaEnv
}
// env.d.ts
declare module '*.vue' {
import { DefineComponent } from 'vue';
const component: DefineComponent<{}, {}, any>;
export default component;
}
2.tsconfig.app.json
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": false,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"skipLibCheck":true,
"types": [
"node",
"jest",
"webpack-env"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"tests/**/*.ts",
"tests/**/*.tsx",
"src/**/*.vue",
"./env.d.ts"
],
"exclude": [
"node_modules",
"src/**/*.vue"
]
}