要解决Angular 8样式问题,可以尝试以下方法:
This is my component
.my-component {
color: red;
}
/* styles.css */
.my-component {
color: red;
}
import { Component, HostBinding, HostListener } from '@angular/core';
@Component({
selector: 'app-my-component',
template: 'This is my component',
styles: ['div { color: red; }']
})
export class MyComponent {
@HostBinding('style.background-color') backgroundColor = 'yellow';
@HostListener('mouseenter')
onMouseEnter() {
this.backgroundColor = 'green';
}
@HostListener('mouseleave')
onMouseLeave() {
this.backgroundColor = 'yellow';
}
}
这些方法可以帮助您解决Angular 8样式问题。根据您的具体需求选择适合您的方法。