Vue + typescript - TypeError: Object prototype may only be an Object or null: undefined

后端 未结 6 1354
你的背包
你的背包 2020-12-19 07:48

TypeError: Object prototype may only be an Object or null: undefined

I got some error in my project. I\'m using vuejs, typescript and jest.

It\'s just simp

6条回答
  •  甜味超标
    2020-12-19 08:46

    The problem seems to be how Vue2 exposes itself, so import Vue from "vue" causes this error.

    I fixed it by using 'vue-property-decorator' like this:

    import { Vue, Component, Prop } from 'vue-property-decorator';
    

    So what does 'vue-property-decorator' do? It imports and then exports Vue not as default but named export. I guess you could do that in your own code, if you wanted.

    import Vue, { PropOptions, WatchOptions } from 'vue';
    ...
    export { Component, Vue, mixins as Mixins };
    

提交回复
热议问题