使用后缀(?raw、?url等)时出现打字错误



当我尝试导入带有后缀(?组件(的SVG时,我的vite项目中出现了一个typescript错误。如何配置typescript以忽略这些后缀?

TS2307: Cannot find module './desktop-mark.svg?component' or its corresponding type declarations.

import DesktopLogoMark from './desktop-mark.svg?component';

您需要添加模块声明:https://www.typescriptlang.org/docs/handbook/modules.html#wildcard-模块声明

最新更新