Vue3项目引入.ts文件报错:An import path can only end with a ‘.ts‘ extension when ‘allowImportingTsExtensions‘

An import path can only end with a ‘.ts’ extension when ‘allowImportingTsExtensions’ is enabled.ts-plugin(5097)
这个错误消息表明在 TypeScript 项目中,当 allowImportingTsExtensions 未启用时,导入路径不能以 .ts 扩展名结尾。

解决方案

启用 allowImportingTsExtensions

在TypeScript 配置文件(通常是 tsconfig.json)中,可以找到 "compilerOptions" 部分,并添加或确保以下选项存在:

{
  "compilerOptions": {
    "allowImportingTsExtensions": true
  }
}

保存配置后,允许在导入时使用 .ts 扩展名。

你可能感兴趣的:(项目经验,vue.js)