vue.js - 调试 Vue 运行时错误的技巧

标签 vue.js vuejs2 quasar-framework

我有一个错误在运行时出现在控制台中,但它正在构建并且我的 linting 过程没有问题。

Uncaught SyntaxError: missing ) after argument list
    at Object.<anonymous> (app.js:958)
    at __webpack_require__ (app.js:708)
    at fn (app.js:113)
    at eval (store.js?adc6:1)
    at Object.<anonymous> (app.js:913)
    at __webpack_require__ (app.js:708)
    at fn (app.js:113)
    at eval (router.js?15ee:1)
    at Object.<anonymous> (app.js:1155)
    at __webpack_require__ (app.js:708)

我知道这是我的代码的问题,任何人都不可能告诉我问题出在哪里,但我正在寻找有关如何调试它的建议。我检查了最近更改的所有文件,但找不到错误。

对于无需遍历每一行代码即可找到此错误源的过程,有没有人有任何建议?

最佳答案

如果你使用的是 vue 2.5+,你可以实现一个新的错误处理功能

这是发行说明的链接:https://gist.github.com/yyx990803/9bdff05e5468a60ced06c29c39114c6b#error-handling-with-errorcaptured-hook

简而言之,您可以将 errorCaptured 添加到您怀疑会抛出错误的组件中

errorCaptured (err, vm, info) {
    this.error = `${err.stack}\n\nfound in ${info} of component`
    return false
}

这应该可以减少您查找错误所花费的时间

关于vue.js - 调试 Vue 运行时错误的技巧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47128014/

相关文章:

javascript - 使用 Vue.js 更改 DOM 元素的值

javascript - vue中如何按页码或上一页下一页显示内容?

javascript - 使用组件甚至无需声明它

typescript - `TypeORM` 和 `Electron` 在尝试访问数据库时导致 "This option/function is not supported in the browser environment"错误

webpack-dev-server - 类星体 Assets 与静态目录

html - Vue单文件组件绑定(bind)data-v-xxxxxxxx到生成的元素

html - 在Vue JS模板中为标题属性添加换行符

javascript - Vue.JS 中的嵌套组件渲染和绑定(bind)

arrays - 如何更新 vue 3 中 ref 内数组的值

javascript - 动态渲染vue模板