Vimo's Blog - mockjs
type: channel
link: https://blog.vimo.cloud/tag/mockjs/
items: xhr.upload.addEventListener is not a function

xhr.upload.addEventListener is not a function
type: item
date: 2023-02-05T21:43:00+08:00
description: 场景在vue中，使用qiniu-js上传文件时报错报错信息TypeError: xhr.upload.addEventListener is not a function解决方法方法一在 node_modules/mockjs/dist/mock.js 第8308行 和 node_modules/mockjs/src/mock/xhr/xhr.js 第216行添加如下代码：MockXMLHttpRequest.prototype.upload = xhr.upload;项目测试和线上是自动打包上传的，所以不会把这两句代码打包进去方法二删除mock的模块npm uninstall mockjs