我代码上的错误是警报,而不是console.errors

时间:2019-01-23 17:23:56

标签: javascript vue.js vue-cli

我正在研究Vue.js项目,并且突然出现错误,而不是控制台上的错误(console.error)是警报(正常的浏览器警报)。

示例。我强迫写(undefined).anyProperty

时出错

Error on alert instead of console

控制台外观:

normal console

我的package.json模块:

"dependencies": {
    "axios": "^0.18.0",
    "bootstrap-vue": "^2.0.0-rc.11",
    "naranja": "^1.0.2",
    "vue": "^2.5.2",
    "vue-router": "^3.0.1",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "autoprefixer": "^7.1.2",
    "babel-core": "^6.22.1",
    "babel-helper-vue-jsx-merge-props": "^2.0.3",
    "babel-loader": "^7.1.1",
    "babel-plugin-syntax-jsx": "^6.18.0",
    "babel-plugin-transform-runtime": "^6.22.0",
    "babel-plugin-transform-vue-jsx": "^3.5.0",
    "babel-preset-env": "^1.3.2",
    "babel-preset-stage-2": "^6.22.0",
    "chalk": "^2.0.1",
    "copy-webpack-plugin": "^4.0.1",
    "css-loader": "^0.28.0",
    "extract-text-webpack-plugin": "^3.0.0",
    "file-loader": "^1.1.4",
    "friendly-errors-webpack-plugin": "^1.6.1",
    "html-webpack-plugin": "^2.30.1",
    "node-notifier": "^5.1.2",
    "node-sass": "^4.11.0",
    "optimize-css-assets-webpack-plugin": "^3.2.0",
    "ora": "^1.2.0",
    "portfinder": "^1.0.13",
    "postcss-import": "^11.0.0",
    "postcss-loader": "^2.0.8",
    "postcss-url": "^7.2.1",
    "rimraf": "^2.6.0",
    "sass-loader": "^7.1.0",
    "semver": "^5.3.0",
    "shelljs": "^0.7.6",
    "uglifyjs-webpack-plugin": "^1.1.1",
    "url-loader": "^0.5.8",
    "vue-loader": "^13.3.0",
    "vue-style-loader": "^3.0.1",
    "vue-template-compiler": "^2.5.2",
    "webpack": "^3.6.0",
    "webpack-bundle-analyzer": "^2.9.0",
    "webpack-dev-server": "^2.9.1",
    "webpack-merge": "^4.1.0"
  },
  "engines": {
    "node": ">= 6.0.0",
    "npm": ">= 3.0.0"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]

我可以在警报中调试,因为对象是[对象对象],谢谢帮助。

3 个答案:

答案 0 :(得分:1)

所以我为您做了一些研究,但实际上还没有检验我的假设,因此请带着一点盐...

我的直觉告诉我,在代码中的某处,有一个附加到窗口错误事件的事件处理程序,该事件处理程序警告错误消息并吞下错误。在代码库中搜索addEventHandler('error'addEventHandler("error"onerror,然后删除它:-)

答案 1 :(得分:1)

我对Vue一无所知,但我建议对此进行调试,是将window.alert函数替换为您自己的包含debugger的函数

let oldWindowAlert = window.alert;
window.alert = function(){ 
  debugger; 
  oldWindowAlert.apply(window, arguments); 
}

然后,当您抓住调试器后,就可以调查调用堆栈(在Chrome中这很容易),以查明发出此警报的函数。

答案 2 :(得分:0)

The docs使我相信Node_Notifier是罪魁祸首。很难看到而不看代码,但是也许看到如果删除它会发生什么?