Vue 'export default' vs 'new Vue'

后端 未结 4 389
轮回少年
轮回少年 2021-01-29 18:21

I just installed Vue and have been following some tutorials to create a project using the vue-cli webpack template. When it creates the component, I notice it binds our data ins

4条回答
  •  借酒劲吻你
    2021-01-29 19:01

    Whenever you use

    export someobject
    

    and someobject is

    {
     "prop1":"Property1",
     "prop2":"Property2",
    }
    

    the above you can import anywhere using import or module.js and there you can use someobject. This is not a restriction that someobject will be an object only it can be a function too, a class or an object.

    When you say

    new Object()
    

    like you said

    new Vue({
      el: '#app',
      data: []
    )}
    

    Here you are initiating an object of class Vue.

    I hope my answer explains your query in general and more explicitly.

提交回复
热议问题