小编Fil*_*ski的帖子

Apollo不可分配给'VueClass <Vue>类型的参数

我正在使用打字稿构建nuxt.js应用程序。这是我的代码:

<script lang='ts'>
    import {Component, Vue} from 'nuxt-property-decorator';
    import {LOCATION} from '~/constants/graphql/location';

    @Component({
        apollo: {
            getLocation: {
                query: LOCATION,
                variables(): object {
                    return {
                        id: 10,
                    };
                },
                prefetch: true,
            },
        },
    })
    export default class Home extends Vue {
    }
</script>
Run Code Online (Sandbox Code Playgroud)

我有错误:

Argument of type '{ apollo: { getLocation: { query: any; variables(): object; prefetch: boolean; }; }; }' is not assignable to parameter of type 'VueClass<Vue>'.
Run Code Online (Sandbox Code Playgroud)

对象文字只能指定已知的属性,而'apollo'在'VueClass'类型中不存在。

我知道它来自TS,但如何解决?

javascript typescript apollo vue.js nuxt

6
推荐指数
1
解决办法
335
查看次数

标签 统计

apollo ×1

javascript ×1

nuxt ×1

typescript ×1

vue.js ×1