如何使以下代码与 IE 一起工作
How can I make the following code work with IE
以下代码是用ES6写的:
我如何转换为 ES6 之前的版本以使其与 IE 兼容。我试着跟随;请参阅下面的第二个代码片段
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;
}
您可以使用在线 transpiler babel
或者如果您在一个完整的项目中工作
with ES6
所以使用 task runner 会帮助你喜欢 [webpack, gulp]
或者只是修复你的 promises
使用第三方,比如 BlueBird
它用于 polyfill
旧浏览器中的承诺
<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js"></script>
以下代码是用ES6写的: 我如何转换为 ES6 之前的版本以使其与 IE 兼容。我试着跟随;请参阅下面的第二个代码片段
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;
}
您可以使用在线 transpiler babel
或者如果您在一个完整的项目中工作
with ES6
所以使用 task runner 会帮助你喜欢 [webpack, gulp]
或者只是修复你的 promises
使用第三方,比如 BlueBird
它用于 polyfill
旧浏览器中的承诺
<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js"></script>