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