preface

How do you deal with errors in vUE in your projects?

Try {}catch{} or use this.$message.error() to raise an error message in vue; Is there anything else you can do about it?

Have you ever considered other ways to handle errors in your project? Usually did not pay attention to, until others asked, suddenly woke up, so the little sister decided to seriously sort out the vUE error processing method?

Vue.js errorHandler

Shocked by his description, he put it into practice:

In the project main.js, configure:

Vue. Config. errorHandler = function (err, vm, info) {console.log(' in ~'); }Copy the code

If (a.length>1) {if(a.length>1) {if(a.length>1);

Errors in the code will not appear in the console. If you want to see error messages, just print error console.log(err) in the configuration above.