编译,识别文件用的
vite构建项目
vscode安装了vueoffical插件则默认不报错
如
import { createApp } from 'vue'
import './style.css'
import App from './App.vue' // .vue文件无法被编译识别
createApp(App).mount('#app')
在vite-env.d.ts中声明后被识别
/// <reference types="vite/client" />
declare module "*.vue" {
import type { DefineComponent } from "vue";
const component: DefineComponent;
export default component;
}
不论是否安装插件,最好都在vite-env.d.ts中声明
叫env.d.ts也可