我想使用Vuejs和打字稿和格格不入。
类型记录的插件使用是gridsome-plugin-typescript.。
这是我的<script>
<script lang='ts'>
import Vue from "vue"
export default Vue.extend({
metaInfo: {
title: 'About us'
}
})
</script>我得到了以下错误:
No overload matches this call.
The last overload gave the following error.
Argument of type '{ metaInfo: { title: string; }; }' is not assignable to parameter of type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>>'.
Object literal may only specify known properties, and 'metaInfo' does not exist in type 'ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>>'它似乎与不接受参数的插件有关。但不确定。
发布于 2020-08-12 01:53:42
我似乎找到了正确的配置(vue-shims.d.ts):
旧坏配置
declare module "*.vue" {
import Vue from "vue";
export default Vue;
}
declare module "vue/types/options" {
interface ComponentOptions<V extends Vue> {
metaInfo?: any;
}
}我意识到这里有些奇怪的地方是因为在依赖关系中:node_node/vue-meta/type/vue.d.ts是一个声明,用于做同样的事情。此外,同一文件中的index.d.ts导出默认值和文字对象.
修正代码:
declare module "*.vue" {
import * as Vue from "vue";
export default Vue;
}A您现在可以看到声明import *作为Vue。
认为答案是正确的,但如果有一个反馈乐于阅读。
发布于 2020-08-10 08:30:08
看看这个问题!这是对你的帮助:)
https://stackoverflow.com/questions/63144450
复制相似问题