Vue3+Vite+TypeScript 中 TS 文件export type类型报错

使用的环境为Vite+Vue3+TypeScript。

报错信息如下:

Uncaught SyntaxError: The requested module 'xx.d.ts' does not provide an export named 'CustomRoute'

定义的对应的ts文件如下:

import { RouteRecordRaw } from "vue-router";

export type CustomRoute = RouteRecordRaw & {
  hidden?: boolean;
};

解决方法:
在 import 的时候将 import {xxx} from 'xxx'  改成 import type {xxx} from 'xxx'

猜你喜欢

转载自blog.csdn.net/jexxx/article/details/128657545