::ng-deep going to be deprecated - Any alternatives?

后端 未结 2 1133
忘了有多久
忘了有多久 2020-12-04 23:40

Doc says:

The shadow-piercing descendant combinator is deprecated and support is being removed from major browsers and tools. As such we plan to drop

2条回答
  •  不知归路
    2020-12-05 00:27

    One alternative that can work is to include the css styles in your global styles.scss file*.

    For example, say you want to add a style to the

    element that gets generated under a , you could use ::ng-deep likewise:

    your.component.scss

    ::ng-deep mat-form-field.mat-form-field div.mat-form-field-flex {
      padding: 0 0 0 .75em;
    }
    

    Or instead, you can change:

    styles.scss:

    mat-form-field.mat-form-field  div.mat-form-field-flex {
      padding: 0 0 0 .75em;
    }
    

    *: This is any file that is added to the styles collection in your angular.json file.

    "styles": [
              "src/theme.scss",
              "src/styles.scss"
            ],
    

提交回复
热议问题