gpt4 book ai didi

vue.js - 我怎样才能在 vue devtools 中显示错误?

转载 作者:行者123 更新时间:2023-12-05 05:19:42 27 4
gpt4 key购买 nike

我已经安装了 Vue Devtootls,但每次出现错误时它都不会显示在控制台中,我看到 o laracast 他们有 [vue: warn] 和错误。我放了这段代码,但什么也没有。

catch(function(error){ console.log(error.message); });
}

最佳答案

我觉得你对vue-devtools有误解,vue-devtools是一个浏览器扩展,用作调试工具。您可以通过它检查您的组件、事件和更多信息。请看一下它的introduction在 GitHub 上。

vue-devtools

另一方面,像 [vue: warn] ... 这样的消息是由 Vue 本身产生的。我认为您没有收到消息的原因仅仅是因为您使用了 vue.min.js 而不是 vue.js。将以下代码保存为 html 文件,然后在 chrome 中打开它。您应该能够在 Chrome 的控制台中看到警告消息。

<!DOCTYPE html>
<html>
<head>
<title>Vue test</title>
</head>
<body>
<script type="text/javascript" src="https://unpkg.com/vue@2.4.2/dist/vue.js"></script>
<div id="app">
<span>{{ message }}</span>
<component1></component1>
</div>
<script>
// Vue.component('component1', {
// template: '<button>{{ message }}</button>',
// data: function() {
// return {
// message: 'I am a test button'
// };
// }
// });
var vm = new Vue({
el: '#app',
data: {
message: 'hello'
},
});
</script>
</body>
</html>

vue-warn

关于vue.js - 我怎样才能在 vue devtools 中显示错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45663462/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com