Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xhr.addEventListener is not a function(…) #127

Closed
MillerRen opened this issue Jul 25, 2016 · 7 comments
Closed

xhr.addEventListener is not a function(…) #127

MillerRen opened this issue Jul 25, 2016 · 7 comments

Comments

@MillerRen
Copy link

vue vue-resource webpack 文件上传提示 xhr.addEventListener is not a function(…),好像是这个方法被重命名成了 xhr.addEventListene即少了个r

@MillerRen
Copy link
Author

#105 重复

@geetwo
Copy link

geetwo commented May 6, 2017

Hey this is not a repeat of issue #105 i guess.
xhr.addEventListener works fine but xhr.upload.addEventLister doesnt work therefore i am not able to geat file upload progress event not even when using xhr.upload.onprogress.

Please Help with this

@Telanx
Copy link

Telanx commented Jun 15, 2017

@geetwo just add the code below to the file node_modules/mockjs/dist/mock.js at line 8308

MockXMLHttpRequest.prototype.upload = xhr.upload;

@nooldey
Copy link

nooldey commented Sep 19, 2017

@Telanx the better way is to change the file node_modules/mockjs/src/xhr/xhr.js at line 216
(更建议的做法是在以上路径文件的第216行,添加如下代码:)

MockXMLHttpRequest.prototype.upload = xhr.upload;

确保在生产模式下打包出来的代码正常使用。

@losymear
Copy link

@nooldey 新版本的mockjs需要加到哪一行呢

@waketzheng
Copy link

waketzheng commented May 28, 2019

@losymear 一样的放在216行就好. 我的mockjs版本是1.0.1-beta3
然后还要删除 node_modules/mockjs/dist/ , 并重新npm run dev

  • 另外, 直接删除mockjs包和对它的引用, 也是能解决问题的

@greper
Copy link

greper commented Oct 22, 2019

我fork修复了这个问题
将原有的mockjs从packag.json中删除
然后执行 npm i mockjs-x --save 即可

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants