Vue.js: Why Components’ Data Properties Must Be Functions

May 2, 2017 by
Part 52 of 55 in the Vue.js: From Beginner to Professional series

I previously mentioned that with components, the data property must be a function and not an object as we are used to. I have opened up an example of a component which contains a button. <div id="app"> <counter></counter> </div> Vue.component(‘counter’, { template: ` <div> <button @click="counter++">{{ counter }}</button> </div> ` }); new Vue({ el: ‘#app’… read more