angular - 为什么我们在 Angular 的组件中传递数组中的样式?

标签 angular

@Component({
  selector: 'app-course',
  templateUrl: './course.component.html',
  styleUrls: ['./course.component.css'],
  styles:[
  `


  `],
})

为什么我们在 Angular 的组件中传递数组样式而不像模板?

最佳答案

参见 this阅读更多内容并查看给出的示例。您可以将多个 CSS 样式作为数组添加到该 component。 例如,

@Component({
  selector: 'hero-app',
  template: `
    <h1>Tour of Heroes</h1>
    <h2>Sub Heading</h2>
    <hero-app-main [hero]=hero></hero-app-main>`,
  styles: ['h1 { font-weight: normal; font-size: 20px; }', 'h2 { font-size: 14px; }']
})
export class HeroAppComponent {
/* . . . */
}

关于angular - 为什么我们在 Angular 的组件中传递数组中的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46255301/

相关文章:

angular - 在 Angular 6 中导入 Bootstrap angular.json 错误 : ENOENT: no such file or directory

angular - ngFor 只显示数组中的第一项

javascript - 导航到另一个模块中的组件(Angular)

css - 什么是 `styles.css.less` 和 `styles.css.scss` 文件

html - 如何以 Angular 禁用特定日期之前的所有日期?

Angular2 + webpack 不显示图像

css - Angular 5动画进入(void => state)有效但离开(state => void)无效

angular - 如何在 ngFor 中使用响应式表单

javascript - Angular:单击按钮时无法更新类中的属性

当包含 cordova.js 时,Angular Cordova 应用程序变为空白