有没有实现在IE9的承诺的一种方式+ [英] is there a way to implement promises in ie9+

查看:106
本文介绍了有没有实现在IE9的承诺的一种方式+的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我米试图实现的本地承诺在 IE9 + 并似乎Internet Explorer不承认无极类/对象
我搜索在 http://caniuse.com/#search=Promise ,看到的 IE 唐'T有希望的对象。
但是,这很奇怪,因为的jQuery 与承诺的工作和在IE9 +工作。
也许他们正在实施的自己的承诺?? **
我可以实现我自己的承诺?**

I m trying to implement native promise on IE9+ and it seems that internet explorer does not Recognize the "Promise" class/object. I searched in http://caniuse.com/#search=Promise and saw that IE don't have Promise object. But this is strange because jQuery and Angular works with promises and working in IE9+. Maybe they are implementing their own Promise?? ** Can i implement my own promise ?**

推荐答案

作为本土意味着它的写入浏览器的code在的用户级code碱基,而不是。为了在IE9本身实现的诺言,你不得不从微软获得IE9源$ C ​​$ C的副本,code的,汇编和分发。虽然这是可行的,这不是一个可行的选择。

What's "native"

Being native means that it is written inside the browser's code base and not in user-level code. In order to implement promises natively in IE9 you'd have to obtain a copy of the IE9 source code from Microsoft, code those in, compile and distribute it. While that's doable that's not a very viable option.

在另一方面 - 有中存在的用户级的若干承诺库。这是完全有可能实现自己的诺言的实现 - 正在就如何伟大的博客文章。

On the other hand - there are several promise libraries that exist in userlevel. It's perfectly possible to implement your own promise implementation - here is a great blog post on how.

您可以自由包括像蓝鸟库(蓝鸟)或Q是实现这一API,并将继续在未来ES6承诺运作良好。值得一提的是,蓝鸟比如运行在IE6 +,所以应该在你的情况没有问题。

You can freely include a library like bluebird (bluebird) or Q that fulfill this API and will continue working well with ES6 promises in the future. It is worth mentioning that Bluebird for instance runs on IE6+ so there should be no issues in your case.

有关此例如是角的实现,这里是<一个HREF =htt​​ps://github.com/jquery/jquery/blob/master/src/deferred.js> jQuery的实现 - 角的是在我看来,更具有可读性。

For example here is Angular's implementation and here is jQuery's implementation - Angular's is more readable in my opinion.

另外请注意,违反上述承诺离开COMENT的的用象角库的承诺/ A +规格标准化,符合并像jQuery库在兼容工作,并可能会在下一版本。本机还承诺遵守标准和超集吧。

Also note that contrary to the coment left above promises are standardized by the Promises/A+ specification with libraries like Angular conform to and libraries like jQuery are working on conforming to and likely will in the next version. Native promises also conform to the standard and superset it.

这篇关于有没有实现在IE9的承诺的一种方式+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆