Vue.extend (opciones)

Vue.extend (opciones)

Arguments:
    {Object} options

Usage:

Create a “subclass” of the base Vue constructor. The argument should be an object containing component options.

The special case to note here is the data option - it must be a function when used with Vue.extend().

<div id="mount-point"></div>

// create constructor
var Profile = Vue.extend({
  template: '<p>{{firstName}} {{lastName}} aka {{alias}}</p>',
  data: function () {
    return {
      firstName: 'Walter',
      lastName: 'White',
      alias: 'Heisenberg'
    }
  }
})
// create an instance of Profile and mount it on an element
new Profile().$mount('#mount-point')

Will result in:

<p>Walter White aka Heisenberg</p>

See also: Components
133 artículos originales publicados · elogiados 189 · 10,000+ vistas

Supongo que te gusta

Origin blog.csdn.net/blog_programb/article/details/105603307
Recomendado
Clasificación