What is Vue.extend for?

后端 未结 5 922
[愿得一人]
[愿得一人] 2020-12-15 02:48

This is a simple enough one, but I\'m not getting the answer I need from the documentation. I\'m in the process of learning Vue.js, and I don\'t really understand where Vue.

5条回答
  •  [愿得一人]
    2020-12-15 02:59

    There guide in previous Vuejs.org site had a document.

    Copy from http://optimizely.github.io/vuejs.org/guide/composition.html which is forked from vuejs/Vuejs.org at version 0.10.6 of Vuejs.

    It is important to understand the difference between Vue.extend() and Vue.component(). Since Vue itself is a constructor, Vue.extend() is a class inheritance method. Its task is to create a sub-class of Vue and return the constructor. Vue.component(), on the other hand, is an asset registration method similar to Vue.directive() and Vue.filter(). Its task is to associate a given constructor with a string ID so Vue.js can pick it up in templates. When directly passing in options to Vue.component(), it calls Vue.extend() under the hood.

    Vue.js supports two different API paradigms: the class-based, imperative, Backbone style API, and the markup-based, declarative, Web Components style API. If you are confused, think about how you can create an image element with new Image(), or with an tag. Each is useful in its own right and Vue.js tries to provide both for maximum flexibility.

提交回复
热议问题