使用/deep/和>>>在Angular 2中 [英] The use of /deep/ and >>> in Angular 2

查看:215
本文介绍了使用/deep/和>>>在Angular 2中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读此选择器,并得到相互矛盾的答案.

I've been reading up on this selector, and getting conflicting answers.

在:做什么/deep/和: :shadow在CSS选择器中是什么意思?

我们看到了:

正如Joel H.在评论中指出的那样,Chrome自此不再推荐使用 /deep/combinator,它会在IE中产生语法错误.

As Joel H. points out in the comments, Chrome has since deprecated the /deep/ combinator, and it gives a syntax error in IE.

在: https://github.com/Microsoft/vscode/issues/7002

我们看到了:

/deep/不再存在,所以我认为我们不应该支持它. >>>是 新版本,可能应该受支持

/deep/ no longer exists, so I don't think we should support it. >>> is the new version, which should probably be supported

但是,在Angular 2文档中: https://angular. io/docs/ts/latest/guide/component-styles.html

However, in the Angular 2 docs: https://angular.io/docs/ts/latest/guide/component-styles.html

我们看到了:

/deep/选择器也具有别名>>>.我们可以使用 两个可以互换.

The /deep/ selector also has the alias >>>. We can use either of the two interchangeably.

显然,相信Angular 2文档是明智的选择,但是由于所有这些相互矛盾的信息,我有点犹豫.

Obviously it would be wise to trust the Angular 2 docs, but I'm a bit hesitant because of all this conflicting information.

实际上,在最新版本的Microsoft Visual Studio Code中,/deep/>>>都创建了错误,尽管尽管出现错误,它们都可以工作.

In fact, in the latest version of Microsoft Visual Studio Code, BOTH /deep/ and >>> create errors, though they both do work despite the errors.

我的问题有两个:

  1. /deep/待在这里吗?我们是否有任何来源,报价单或任何说明可以采用的规范中的任何内容?还是已正式弃用?

  1. Is /deep/ here to stay? Do we have any source, a quote, or anything from any specification saying that it will be adopted? Or if it has officially been deprecated?

我们可以在不完全禁用语法检查的情况下在Visual Studio Code中抑制此错误吗?

Can we suppress this error in Visual Studio Code without all-together disabling syntax checking?

推荐答案

/deep/待在这里吗?我们是否有任何来源,报价单或任何说明可以采用的规范中的任何内容?还是正式弃用了它?

Is /deep/ here to stay? Do we have any source, a quote, or anything from any specification saying that it will be adopted? Or if it has officially been deprecated?

/deep/语法已过时,最后一次出现在css-scoping 2014年,而其替代产品>>>大约半年前在Chrome 45中已被弃用.

The /deep/ syntax is obsolete, last seen in css-scoping in 2014, and its replacement >>> was deprecated about half a year ago in Chrome 45.

影子穿透后代组合器的整个概念是计划从影子DOM中完全删除.实现可以完全将其删除,也可以将其别名为常规后代组合器(这取决于将来对Shadow DOM的实现方式是否有意义).

The entire concept of the shadow-piercing descendant combinator is slated to be removed from the Shadow DOM entirely. Implementations may either remove it altogether or alias it to the regular descendant combinator (which depending on how the Shadow DOM is implemented in the future may or may not make sense).

我们可以在不完全禁用语法检查的情况下在Visual Studio Code中抑制此错误吗?

Can we suppress this error in Visual Studio Code without all-together disabling syntax checking?

不幸的是.

出于兼容性目的,Angular允许在模拟视图封装中同时使用这两种方法,但是强烈建议作者继续使用>>>,因为/deep/从技术上来说现在是无效的,因此本机视图封装不支持该功能.

Angular allows both in emulated view encapsulation for compatibility purposes, but authors are strongly encouraged to use >>> going forward, since /deep/ is technically invalid now, and therefore unsupported in native view encapsulation.

这篇关于使用/deep/和>>>在Angular 2中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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