[Vue] UI component uploads pictures, burst xhr.upload.addEventListener is not a function error

This problem is mainly because I used mock.js when writing the background management. It changed  the name of the XhrRequest  object to MockXhrRequest  , so the above error was reported, but it was impossible to uninstall it after using it to simulate data. Drop, then start in the node_modules file. The solution steps are as follows:

First find line 8312 in node_modules/mockjs/dist/mock.js (the first file shown below), and add the following code:

MockXMLHttpRequest.prototype.upload = xhr.upload;

Icon to join!

 

 Then find line 216 of node_modules/mockjs/src/mock/xhr/xhr.js  (the second file shown above) and add the above line of code again.

 Then it's done!

Guess you like

Origin blog.csdn.net/m0_62811051/article/details/128245784