In actual development, we may need to get some attributes created when the component declaration is declared. Typically, it is the name attribute. When you need to locate the problem in actual development, you need to find which component it is. However, it is impossible for us to first find the name attribute of the component when writing code, and then copy and paste it to the function as parameters.
For example:
catchError('componentsName', 'errorDescription')
Too stupid.
The solution is to obtain this of the component, and then use this to get the name attribute of the component. In this way, the code can be written like this:
(this, 'errorDescription')
We just need to focus on the wrong description (maybe the wrong description is also a variable, so it will be simpler).
The content of the catchError function should be written like this:
function catchError (url) { (`${this.$} In the component,The following image link does not exist,Or cannot be opened:${url}`) // Here you can write a reported ajax request // ... do some code }
The perfect solution!
The above method of obtaining component declarations in Vue is all the content I share with you. I hope you can give you a reference and I hope you support me more.