Sov*_*iut 20 typescript vue.js
我有一个简单的 Vue 3 项目,它使用 TypeScript,并且在运行时出现以下错误vue-tsc --noEmit。
error TS6504: File '/proj/src/pages/Index.vue.__VLS_template.jsx' is a JavaScript file. Did you mean to enable the 'allowJs' option?
The file is in the program because:
Root file specified for compilation
error TS6504: File '/proj/src/pages/Index.vue.js' is a JavaScript file. Did you mean to enable the 'allowJs' option?
The file is in the program because:
Root file specified for compilation
error TS6504: File '/proj/src/pages/PassLayout.vue.__VLS_template.jsx' is a JavaScript file. Did you mean to enable the 'allowJs' option?
The file is in the program because:
Root file specified for compilation
error TS6504: File '/proj/src/pages/PassLayout.vue.js' is a JavaScript file. Did you mean to enable the 'allowJs' option?
The file is in the program because:
Root file specified for compilation
Run Code Online (Sandbox Code Playgroud)
有问题的文件Index.vue没有PassLayout.vue节<script>;他们<template>只是。
PassLayout.vue
<template>
<router-view />
</template>
Run Code Online (Sandbox Code Playgroud)
为什么我会收到这些错误?
Sov*_*iut 47
如果没有显式指定<script>带有 thelang="ts"属性的块,vue-tsc 会假定该文件是 JavaScript 而不是 TypeScript。
要么"allowJs": true在compilerOptions您的tsconfig.json.
或者将以下内容添加到任何没有显式脚本块的单文件组件中。
<script setup lang="ts"></script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8379 次 |
| 最近记录: |