Vue.extend()

Vue.extend( options )

  • Arguments:

    • {Object} options
  • Usage:

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

    The special cases to note here are el and data options - they must be functions when used with Vue.extend().

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

    Will result in:

    <p>Walter White aka Heisenberg</p>
  • See also: Components

doc_VueJS
2016-09-25 05:48:22
Comments
Leave a Comment

Please login to continue.