4 回答

TA贡献1853条经验 获得超18个赞
如果样式存在于角度组件的文件中,由于视图封装,它将不会被应用。您需要在全局样式表中指定样式,并且在大多数情况下您需要添加important到样式中。
为了进一步阐述,
-src
-assets
-calendar.css (add styles here)
-app
-my-calendar
-my-calendar.page.html
-my-calendar.page.ts
-my-calendar.page.css (and not here)
一些常用的自定义项:(assets/calendar.css)
将样式应用于所选日期:
.monthview-selected{
font-weight: bold;
background-color: #F1F1F1 !important;
color: #333 !important;
}
将样式应用于有事件的日期:
.monthview-primary-with-event, .calendar-event-inner{
background-color: #1a92d0!important;
}
禁用日历中的所有边框:
td, th {
border: 0 !important;
}
应用样式后的最终日历:
HTML
<calendar [eventSource]="eventSource" [calendarMode]="calendar.mode" [currentDate]="calendar.currentDate"
(onCurrentDateChanged)="onCurrentDateChanged($event)" (onRangeChanged)="reloadSource(startTime, endTime)"
(onEventSelected)="onEventSelected($event)" (onTitleChanged)="onViewTitleChanged($event)"
(onTimeSelected)="onTimeSelected($event)" step="30" (showEventDetail)="true" formatDayHeader="EEEEE"
allDayLabel="All Day" startHour="9" endHour="20">
</calendar>

TA贡献1834条经验 获得超8个赞
我遇到了同样的问题,并且解决方案与其他答案中所述的封装有关。
样式不适用于子组件
尝试更新您的组件:
@Component({
...
encapsulation: ViewEncapsulation.None // <------
})
export class xxComponent{
然后,您可以根据子类应用样式,例如。
.scss:
.monthview-container {
...;
}

TA贡献1799条经验 获得超6个赞
::ng-deep {
.monthview-selected {
background-color: blue !important;
color: white !important;
border-radius: 50%;
}
}
添加回答
举报