devtools(vConsole)、upload error、monitoring logs
npm install catch-global-error --save
// or
yarn add catch-global-error
import CatchError from 'catch-global-error';
const catchError = new CatchError();
catchError.init({
url: '/api/error/log', // upload error site
});
const a = 1;
console.log(a.b.c);
initialize
options parameter
param | description | type | value | default value |
---|---|---|---|---|
url | the site of uploading error | String | - | - |
method | the method of uploading error | String | get/post | post |
showDevtools | show devtools | Boolean | true/false | false |
urlSwitch | url query for devtools | Object | - | { devtools: 'show' } |
cdn | vConsole cdn | String | - | 'https://res.wx.qq.com/mmbizwap/zh_CN/htmledition/js/vconsole/3.0.0/vconsole.min.js' |
extendFields | add extend field about business or project what you want to send to the service, such as business_line, type | Object | - | - |
show devtools
// 1: init
import CatchError from 'catch-global-error';
const catchError = new CatchError();
catchError.init({
showDevtools: true, // default show Devtools
});
// default: www.***.com?devtools=show
// you can change url query switch
// eq: www.***.com?show=test
import CatchError from 'catch-global-error';
const catchError = new CatchError();
catchError.init({
urlSwitch: {
show: 'test',
},
});
import CatchError from 'catch-global-error';
const catchError = new CatchError();
catchError.init();
window.onclick = () => {
catchError.show();
};
MIT