vue3 ts文件引入js文件的配置

报无法找到模块“.xxxx…js”的声明文件
vue3 ts文件引入js文件的配置_第1张图片

修改tsconfig.json

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowJs": true,  //添加 编译时允许有js
    "allowSyntheticDefaultImports": true, //允许引用没有默认导出的模块
    "outDir": "build", //添加 将输出结构重定向到目录
    "forceConsistentCasingInFileNames": true,
    "useDefineForClassFields": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": [
      "webpack-env",
      "jest"
    ],
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*",// 添加配置
    "src/**/*.tsx",
    "src/**/*.vue",
    "tests/**/*.ts",
    "tests/**/*.tsx"
, "src/shims-vue.d.ts", "src/registerServiceWorker.ts", "src/main.ts", "src/store/index.ts", "src/router/index.ts", "src/store/state/num.state.js", "src/store/state/num.state.js", "src/store/state/userinfo.state.js"  ],
  "exclude": [
    "node_modules",
    "build/**/*" //添加配置
  ]
}

你可能感兴趣的:(javascript,webpack,vue.js)