相关疑难解决方法(0)

用什么代替:: ng-deep

我正在尝试将路由器出口放置的元素设置为有角度,并且要确保生成的元素的宽度为100%

从大多数回复中,我看到我应该使用::ng-deep选择器,但是从Angular的文档中它被弃用了.有替代品::ng-deep吗?

html css angular

53
推荐指数
4
解决办法
2万
查看次数

使用可重用组件时,Angular 7 CSS无法正常工作

我对Angular很新,来自React.js背景.

我做了一个简单的网格组件,如下所示:

grid.component.js

import { Component, OnInit, Input } from '@angular/core';

@Component({
  selector: 'app-grid',
  template: `
    <div [ngStyle]="styles()" [ngClass]="passClass">
      <ng-content></ng-content>
    </div>
  `,
  styles: [`
    div {
      display: flex;
    }
  `]
})
export class GridComponent implements OnInit {
  @Input() direction: string;
  @Input() justify: string;
  @Input() align: string;
  @Input() width: string;
  @Input() passClass: string;

  constructor() { }

  ngOnInit() {
  }

  styles() {
    return {
      'flex-direction': this.direction || 'row',
      'justify-content': this.justify || 'flex-start',
      'align-items': this.align || 'flex-start',
      ...(this.width && { width: this.width }) …
Run Code Online (Sandbox Code Playgroud)

javascript css angular angular7

5
推荐指数
1
解决办法
2310
查看次数

标签 统计

angular ×2

css ×2

angular7 ×1

html ×1

javascript ×1