今天在项目开发中遇到一个 vue3 + Ts 的一个问题,项目运行没问题,但就是代码报ts语法错误,看着比较碍眼,如下:
解决办法:
- 在src目录下创建env.d.ts文件,加入以下代码即可
declare module "*.vue" {
import type { DefineComponent } from "vue";
const component: ComponentOptions | ComponentOptions["setup"];
export default component;
}