css - Angular 2中/deep/和>>>的使用

标签 css angular css-selectors

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

在:What do /deep/ and ::shadow mean in a CSS selector?

我们看到:

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/ 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

我们看到:

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

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

事实上,在最新版本的 Microsoft Visual Studio Code 中,/deep/>>> 都会产生错误,尽管它们都可以在存在错误的情况下工作。

我的问题有两个:

  1. /deep/会留下来吗?我们是否有任何来源、引述或来自任何规范的任何内容表明它将被采用?或者如果它已被正式弃用?

  2. 我们能否在不完全禁用语法检查的情况下在 Visual Studio Code 中抑制此错误?

最佳答案

  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?

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

    shadow-piercing 后代组合器的整个概念是 slated to be removed from the Shadow DOM entirely .实现可能会完全删除它或将其别名为常规后代组合器(这取决于 Shadow DOM 将来的实现方式可能有意义也可能没有意义)。

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

    不幸的是没有。

    出于兼容性目的,Angular 允许在模拟 View 中进行封装,但强烈建议作者继续使用 >>>,因为 /deep/ 现在在技术上是无效的,因此在原生 View 封装中不受支持。

关于css - Angular 2中/deep/和>>>的使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42134355/

相关文章:

像 xaml 一样的 html 元素绑定(bind)

firefox - *|* 这在 CSS 中意味着什么?

html - 表单输入框在 Internet Explorer 8 上没有水平排列

css - 我如何为 IE 编写 CSS。我的代码在 IE10 或 9、7、8 中不起作用?

javascript - Firefox 中的 typescript anchor 标记单击事件不起作用

angular - 如何使用 mat-autocomplete 完全重置 mat-input

node.js - Angular 构建 - 未捕获的类型错误 : Cannot read property 'id' of undefined

html - 对 html 标记中除一个元素(ID/类)之外的每个元素应用效果

html - 中间带有纯文本的相邻 CSS 选择器仍然匹配

html - Bootstrap 4中水平居中 '::before'元素和其他具有flex概念的div元素