WebStorm无法识别@下的文件,但是可以正常使用
报错过程
相关文件
routes.ts:
import type {RouteRecordRaw} from "vue-router"; const routes: RouteRecordRaw[] = [ { path: '/', name: 'index', component: () => import('@/pages/Index.vue') }
] export default routes
vite.config.ts
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';
import path from 'path' // https://vite.dev/config/
export default defineConfig({ plugins: [ vue(), Components({resolvers: [VantResolver()]}) ], resolve: { alias: { '@': path.resolve(__dirname, './src') } }
})
tsconfig.json
{ "files": [], "references": [ { "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" } ], "compilerOptions": { "baseUrl": "./", "paths": { "@/*": ["src/*"] } }, "exclude": ["node_modules", "dist"]
}
报错解决
tsconfig.json添加:
{
..."compilerOptions": { ...}, "include": ["src/**/*"], ...
}