javascriptvue.jsvuejs2decoratorjavascript-decorators

import { Component, Vue } from "vue-property-decorator" vs. import Vue from "vue"


What's the difference and use cases between importing Vue from vue-property-decorator and vue? What I understood I need to import Vue from vue-property-decorator always when defining a custom component with a @Component decorator, but are there any unexpected/different things/scenarios related to the Vue's core which I should be aware when doing so?


Solution

  • I would say that there is no difference according to sources of vue-property-decorator.

    vue-property-decorator just does the following:

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

    Possible that it is done to reduce number of imports in your code:

    import {Vue, Smth1, Smth2}` from 'vue-property-decorator';
    

    vs

    import Vue from 'vue';
    import {Smth1, Smth2} from 'vue-property-decorator';