Vue.JS : TS2339: 属性'...'在类型'{组件上不存在:{



我将Vue与单个文件组件一起使用(实际上,我正试图将这些.Vue组件拆分为3个不同的文件,.Vue具有脚本和样式标记,每个标记都调用一个单独的文件(

但在这个文件中:

import modelsList from '@/components/modelsList/modelsList.vue';
import bookerService from '@/services/booker.ts';
export default {
components: { modelsList },
data: function() {
return {
homeModels: [] as any[],
};
},
created: function() {
this.homeModels = bookerService.getHomeModels();
},
};

我收到错误消息:

TS2339:类型"{components:"上不存在属性"homeModels"{modelsList:VueConstructor;};数据:((=>{homeModels:any[];};已创建:((=>void;}'。

你知道这里发生了什么吗?

还有一个小问题,你知道为什么如果我不在导入中添加文件扩展名,我会收到这样的错误吗:

找不到模块'@/components/modelsList/modelsList'或其相应的类型声明。


这是我的tsconfig.json:

{
"compilerOptions": {
"target": "esnext",
"strict": true,
"module": "esnext",
"moduleResolution": "node",
"baseUrl": "./",
"removeComments": true,
"sourceMap": true,
"paths": {
"@/*": [
"assets/vue/*"
]
},
"esModuleInterop": true,
"jsx": "preserve",
"importHelpers": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"types": [
"webpack-env"
],
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"files": [
"assets/vue/vue-shims.d.ts"
],
"exclude": [
"node_modules"
]
}

OK刚刚发现";包括";tsconfig.json的数组:

不得不更换";src/";每一个的父文件夹都包含到我的vue项目的真实文件夹中,相对于tsconfig.json,就是"assets/vue/";

相关内容

最新更新