创建file对象在IE11里面报错,chrome里面没问题

var file = new File(["foo"], "foo.txt", {
  type: "text/plain",
});

使用上面的代码创建file对象,在ie11里面报Function expected,chrome里面是没问题的

阅读 8.9k
4 个回答

可以修改filename,formData.append第三个参数就是,例子:

formData.append('foo', blob, 'foo.txt');

另外IE中不支持new File的写法,详见https://caniuse.com/#search=file

// let file = new File([dataFile], that.curFilename, {type: dataFile.type, lastModified: Date.now()})

    /* const isLt5M = file.size / 1024 / 1024 < 5
    if (!isLt5M) {
      that.$message.error('剪切后的图片大于5M')
      return
    } */
    let data = new FormData() // operatorId
    // data.append('file', dataFile)     把这行
    data.append('file', dataFile, that.curFilename)  改成这行
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题