2017-08-13 32 views
0

我已经安装了Vue Devtootls,但是每次出现错误时,它都不会在控制台中显示,我看到他们喜欢[vue:warn]和错误。我把这个代码,但没有。如何在vue devtools中显示错误?

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

警告只显示在控制台中,如果您使用非生产Vue公司的(非精缩)版本。 – Bert

+0

你能举个例子吗? –

回答

1

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

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/[email protected]/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