GithubHelp home page GithubHelp logo

Comments (4)

mboo2005 avatar mboo2005 commented on June 3, 2024

加上polyfill ie9下直接报错。
不加polyfill,可以使用,但是返回结果后会error。追踪是这段代码有问题,因为服务器返回的是一段json,没有script,而这里 const script = doc.getElementsByTagName('script')[0]; 取script,导致undefined。 怎么解决?
onLoad = () => {
if (!this.state.uploading) {
return;
}
const { props, file } = this;
let response;
try {
const doc = this.getIframeDocument();
const script = doc.getElementsByTagName('script')[0];
if (script && script.parentNode === doc.body) {
doc.body.removeChild(script);
}
response = doc.body.innerHTML;
props.onSuccess(response, file);
} catch (err) {
warning(false, 'cross domain error for Upload. Maybe server should return document.domain script. see Note from https://github.com/react-component/upload');
response = 'cross-domain';
props.onError(err, null, file);
}
this.endUpload();
}

from upload.

shepherdwind avatar shepherdwind commented on June 3, 2024

@joybee007 引入了什么 polyfill ?

from upload.

shepherdwind avatar shepherdwind commented on June 3, 2024

就加一个 native code 判断可以么,比如这样

typeof FormData !== 'undefined'  && FormData.toString().indexOf('[native code]') > -1

from upload.

joybee007 avatar joybee007 commented on June 3, 2024

@shepherdwind 一个模拟FormData的插件。然而并不支持文件上传。native code判断也算不是方法的方法吧。建议判断浏览器的File类,这个暂时无法模拟~所以几乎不会有人做一个这个polyfill吧。

from upload.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.