1

我正在使用vscode。

  1. 通过 alias 导入时,ctrl + clickwelcome跳转到 shims-vue.d.ts。
// router.config.ts
import welcome from '@pages/welcome/welcome.vue'
  1. 通过相对路径导入时,ctrl+clickwelcome跳转到shims-vue.d.ts,但是clickwelcome.vue可以显示定义信息。
// router.config.ts
import welcome from '../pages/welcome/welcome.vue'
  1. 在 .vue 文件中没问题
<script lang="ts">
  import { defineComponent } from 'vue'
  import welcome from '@pages/welcome/welcome.vue' // can jump to welcome.vue

  export default defineComponent({
    name: 'App',
  })
</script>

这是我的tsconfig.json,有什么问题吗?

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "moduleResolution": "node",
    "strict": true,
    "jsx": "preserve",
    "sourceMap": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "lib": ["esnext", "dom"],
    "baseUrl": ".",
    "paths": {
      "@*": ["src/*"],
      "@api*": ["src/api/*"],
      "@components*": ["src/components/*"],
      "@config*": ["src/config/*"],
      "@enums*": ["src/enums/*"],
      "@store*": ["src/store/*"],
      "@types*": ["src/types/*"],
      "@utils*": ["src/utils/*"],
      "@pages*": ["src/pages/*"],
      "@tests*": ["tests/*"]
    }
  },
  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
}
4

0 回答 0