[Vuejs]-How to uncheck answered question in child vue from parent

0👍

One way would be to use an event bus

in your main js add:

//set up bus for communication
export const bus = new Vue();

in your parent vue:

import {bus} from 'pathto/main.js';

// in your 'reset()' method add:
// this emits an event on the bus with optional 'data' param
bus.$emit('resetChild', data);

in your child vue

import {bus} from 'path/to/main';

// listen for the event on the bus and run your method
mounted(){
    bus.$on('resetChild', this.resetChildMethod());
},
methods: {
  resetChildMethod(){
    //put your reset logic here
  }
}

Leave a comment