errorHandler

errorHandler

Type: Function

Default: undefined

Usage:

Vue.config.errorHandler = function (err, vm, info) {
  // handle error
  // `info` is a Vue-specific error info, e.g. which lifecycle hook
  // the error was found in. Only available in 2.2.0+
}

Assign a handler for uncaught errors during component render function and watchers. The handler gets called with the error and the Vue instance.

    In 2.2.0+, this hook also captures errors in component lifecycle hooks. Also, when this hook is undefined, captured errors will be logged with console.error instead of crashing the app.

    In 2.4.0+, this hook also captures errors thrown inside Vue custom event handlers.

    In 2.6.0+, this hook also captures errors thrown inside v-on DOM listeners. In addition, if any of the covered hooks or handlers returns a Promise chain (e.g. async functions), the error from that Promise chain will also be handled.

    Error tracking services Sentry and Bugsnag provide official integrations using this option.
发布了133 篇原创文章 · 获赞 189 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/blog_programb/article/details/105603262
今日推荐