Vue 'export default' vs 'new Vue'

后端 未结 4 387
轮回少年
轮回少年 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 18:47

    The first case (export default {...}) is ES2015 syntax for making some object definition available for use.

    The second case (new Vue (...)) is standard syntax for instantiating an object that has been defined.

    The first will be used in JS to bootstrap Vue, while either can be used to build up components and templates.

    See https://vuejs.org/v2/guide/components-registration.html for more details.

提交回复
热议问题