I am totally newbie with Vueand I am trying to figure out how can I render dynamic content based on link click. I am getting an error message: Property or method "setLink" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
Here is my VUE code:
Vue.component('navigation', {
template: '#navigation'
})
Vue.component('home', {
template: '#home'
})
Vue.component('about', {
template: '#about'
})
var app = new Vue({
el: '#app',
component: {
navigation
},
data: {
currentView: 'home'
},
methods: {
setLink: function(link) {
this.currentView = link;
}
}
})
and I have div with id app:
<div id="app">
<navigation></navigation>
<div class="container">
<componet :is="currentView"></component>
</div>
</div>
In navigation I have a tag with v-on:click="setLink('someLink')" function. Maybe someone knows where the issue could be? Thank you
setLink
method in yournavigation
component. Even though that component's tag is within #app, it doesn't have references to the main #app component's methods – thanksd