[Vuejs]-Vue on click inside component

2👍

Your component has local scope, meaning it will try and call a next method on the component itself and not on your root instance where you have actually defined your method.

Depending on your situation and what you want you need to either move the method inside your homepage or section2 component.

Or you need to notify your root Vue instance whenever the click event has been called in a child component. There are many communication patterns possible with Vue.js for child-parent communication an easy one would be this:

https://v2.vuejs.org/v2/guide/components.html#Custom-Events

On click you would emit an event from your child component and use a v-on to listen to the event in your root instance.

But by the looks of it you want to implementing routing with one component per page:

https://v2.vuejs.org/v2/guide/routing.html

0👍

in your ‘new App’, when you set ‘el’ property it should refer to an ID of an html element (the root element).

your html should be like this instead:

<div id="homepage">
  <homepage v-if="seen"></homepage>
  <section2 v-else></section2>
</div>

Leave a comment