Vue.js Components Data registration in components


Example

Passing an object to the data property when registering a component would cause all instances of the component to point to the same data. To solve this, we need to return data from a function.

var CustomComponent = Vue.extend({
    data: function () {
        return { a: 1 }
    }
})