Javascript抓取Internet Explorer 8
我使用抓取做了一个脚本,但它在ie8 +中不起作用,它在其他浏览器中正常工作,但在IE中,我已经尝试了一些webpack/gulp插件解决方案,但没有成功。Javascript抓取Internet Explorer 8
我的代码:
(() => {
fetch('/category.json',{
method: 'GET',
headers:{
'Access-Control-Allow-Origin':'*',
"Content-Type": "text/plain"
}
})
.then(response => response.json())
.then(data => changeItems(data.data))
.then(data => sortItems(data))
.then(data => displayData(data, 'ranking'))
})();
为了支持旧的浏览器,你需要添加wg-fetch
polyfills。
使用fetch polyfill。您还需要一个Promise polyfill
我试图使用它,但无济于事我在webpack入口点使用了whatwg-fetch,并将其导入到脚本中,我做错了什么?我的代码 module.exports = {'whatwg-fetch','。/ dev/js/main.js'], 输出:{ path:__dirname +'/ public /', filename:' ./bundle.js' },从'promise-polyfill'导入Promise; (!window.Promise){ window.Promise = Promise; } –
你得到的错误是什么?你是否先用npm安装它们? – glennsl
是的,已安装。错误:'Promise'undefined –
如果您在Google中搜索您的*精确*问题标题,则第一个结果是用于在IE8中激活提取的填充。 –