问题
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