I am using vue.js and try to recreate the "Listening to Events" example. They use the following code:
HTML
<div id="example-1">
<button v-on:click="counter += 1">Add 1</button>
<p>The button above has been clicked {{ counter }} times.</p>
</div>
JS
var example1 = new Vue({
el: '#example-1',
data: {
counter: 0
}
})
I want to do the same, but as its something I will do more often I want to create a component:
HTML
<div id="example-1">
<counterButton></counterButton>
<p>The button above has been clicked {{ counter }} times.</p>
</div>
JS
Vue.component('counterButton', {
template: '<button v-on:click="counter += 1">Add 1</button>'
})
var example1 = new Vue({
el: '#example-1',
data: {
counter: 0
}
})
This does not seem to be working, while I receive the following warning:
[Vue warn]: Property or method "nextPage" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
As I am not used to javascript too much, I am simply not able to understand the error. I guess I have to somehow "link" the data value to my component?
nextPageproperty on your example.