Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
436 views
in Technique[技术] by (71.8m points)

javascript - Apollo不可分配给'VueClass类型的参数<Vue>(Apollo is not assignable to parameter of type 'VueClass<Vue>)

I'm building nuxt.js app with typescript.

(我正在使用打字稿构建nuxt.js应用程序。)

This is my code:

(这是我的代码:)

<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>

I have error:

(我有错误:)

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

Object literal may only specify known properties, and 'apollo' does not exist in type 'VueClass'.

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

I know it's come from TS but how to fix it?

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

  ask by Filip Wroński translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

@Component accept a parameter of the VueClass Type, the items need to be props, components, methods.etc.

(@Component接受VueClass类型的参数,这些项目需要是道具,组件,方法等。)

For example:

(例如:)

@Component({

  components: {

    HelloWorld

}})

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...