如何将 Web Animations API polyfill 添加到使用 Angular CLI 创建的 Angular 2 项目中 [英] How to add Web Animations API polyfill to an Angular 2 project created with Angular CLI

查看:20
本文介绍了如何将 Web Animations API polyfill 添加到使用 Angular CLI 创建的 Angular 2 项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Angular 2 动画文档 指的是 Web Animations API polyfill,适用于不支持原生浏览器的浏览器.

将这个 polyfill 添加到使用 Angular CLI 创建的 Angular 2 项目的正确方法是什么?

(我使用的是 angular-cli: 1.0.0-beta.10)

运气不好,我尝试了这里提到的想法和解决方案:

我通过 NPM 下载并添加到 system-config.ts.我相信这符合推荐的内容,但是 polyfill 没有加载(我可以判断,因为动画在 Safari 中不起作用).

我只是通过在 index.html 中包含 polyfill 来实现这一点,我知道这不是正确的方法:

 <script src="https://rawgit.com/web-animations/web-animations-js/master/web-animations.min.js"></script>

我会在这里添加任何可能有助于澄清我的问题的细节,但如果你需要查看代码,我在 Github 上有:

https://github.com/cmermingas/connect-four

提前致谢!

解决方案

Angular 6 Note - Polyfill 不再需要 :-)

<块引用>

动画性能改进

我们更新了我们的实现的动画不再需要 web 动画 polyfill.这个意味着你可以从你的应用程序中删除这个 polyfill 并保存大约 47KB 的包大小,同时增加了动画Safari 中的性能.

:-)

https://blog.angular.io/version-6-of-angular-now-available-cc56b0efa7a4

The Angular 2 animations documentation refers to the Web Animations API polyfill for browsers that don't support the native one.

What's the proper way to add this polyfill to an Angular 2 project created with Angular CLI?

(I am using angular-cli: 1.0.0-beta.10)

With no luck, I have tried the ideas and solutions mentioned here:

I downloaded it via NPM and added it to system-config.ts. I believe this is along the lines of what's recommended but the polyfill doesn't get loaded (I can tell because the animations don't work in Safari).

I only got this to work by including the polyfill in index.html, which I know it's not the proper way:

  <script src="https://rawgit.com/web-animations/web-animations-js/master/web-animations.min.js"></script>

I will add here any details that may help clarify my question, but if you need to see the code, I have it on Github:

https://github.com/cmermingas/connect-four

Thanks in advance!

解决方案

Angular 6 Note - Polyfill no longer required :-)

Animations Performance Improvements

We’ve updated our implementation of Animations to no longer need the web animations polyfill. This means that you can remove this polyfill from your application and save approximately 47KB of bundle size, while increasing animations performance in Safari at the same time.

:-)

https://blog.angular.io/version-6-of-angular-now-available-cc56b0efa7a4

这篇关于如何将 Web Animations API polyfill 添加到使用 Angular CLI 创建的 Angular 2 项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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