D
D
Denioo2020-08-19 16:15:24
Vue.js
Denioo, 2020-08-19 16:15:24

How to intercept the error of child components from the parent component?

Hello, an unknown error is coming in child components. How can it be intercepted in the parent to block the window from showing the banner? Moreover, it can come on any action, creating, deleting a download. It is displayed in the console, I don’t want to check for a similar error in every action, since it is the same for all child components.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
fostsinger, 2020-08-19
@fostsinger

call $emit function inside child component

methods: {
  example () {
    this.$emit('example', {
      test: this.testParams,
    })
  }
}

parent component
<сhildComponent @example='onExample' />
methods: {
  onExample (data) {
    console.log('child component said', data)
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question