Can't find variable: Promise on iOS 7

醉酒当歌 提交于 2019-12-11 05:18:55

问题


iOS 7 Safari is reporting the error Can't find variable: Promise:

new Promise(function(resolve, reject) {
.
.
.

White other browsers don't have this issue, I found this similar question where Robert gave a solution to add new Ember.RSVP.Promise instead of the new Promise.

My problem is that I'm not using jQuery and that makes all browsers return an error that Ember is not defined, and I found that adding Ember.min.js solves the issue, but that adds extra 129.96 KB to my page which is not good at all to my project.

I just want to fix the problem for iOS7, and I appreciate if somebody who knows how he tell us.


回答1:


You need to include a polyfill for browsers that don't support promises natively. Here is a light weight one that is easy to use:

https://github.com/taylorhakes/promise-polyfill




回答2:


Your browser just simply doesn't support promises, so you must provide one on your own. It's not very hard to implement promises in javascript, you can use already made code or babel.

If you want to implement promises, you can use this one https://gist.github.com/unscriptable/814052



来源:https://stackoverflow.com/questions/41922082/cant-find-variable-promise-on-ios-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!