Javascript 如何使以下代码与IE一起工作
以下代码是使用ES6编写的: 我如何转换到ES6之前的版本,使其与IE兼容。我试图遵循;请参阅下面的第二个代码snipetJavascript 如何使以下代码与IE一起工作,javascript,filepond,Javascript,Filepond,以下代码是使用ES6编写的: 我如何转换到ES6之前的版本,使其与IE兼容。我试图遵循;请参阅下面的第二个代码snipet FilePond.create(document.querySelector('input'), { acceptedFileTypes: ['image/png'], fileValidateTypeDetectType: (source, type) => new Promise((resolve, reject) => {
FilePond.create(document.querySelector('input'), {
acceptedFileTypes: ['image/png'],
fileValidateTypeDetectType: (source, type) => new Promise((resolve, reject) => {
// Do custom type detection here and return with promise
resolve(type);
})
});
i tried the following
FilePond.create(imageInputElement, {
acceptedFileTypes: ['image/png', 'image/x-png', 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/tiff', 'application/pdf'],
fileValidateTypeDetectType: function (source, type) {
return resolveFileType(resolve, reject);
}
})
async function resolveFileType(resolve, reject){
const response = await resolve(type);
return response;
}
你可以使用巴别塔在线或如果你在一个完整的项目工作
使用ES6时,请使用task runner,它将帮助您喜欢[webpack,gulp]
或者只是利用第三方来修正你的承诺,比如BlueBird,它用来填充
旧浏览器中的承诺
<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js"></script>
这回答了你的问题吗?使用babel.js传输ES6。我更愿意将其重写为ES6之前的函数,并用异步函数替换promise?但是我需要一些帮助。那么,你在转化方面做了哪些尝试?什么在转换后的代码中不起作用?你能告诉我们你在转换上述代码方面的尝试吗?我添加了我尝试过的东西。我试过了,非常感谢!但它仍然使用了一个不受IET支持的承诺。它使用了一个叫做bluebird的第三方来履行承诺