[英]Fullcalendar Angular - Tooltip.js CSS is not applied (CSS encapsulation issue)
我已经在Fullcalendar的eventMouseEnter和eventMouseLeave事件上添加了Tooltip.js,但是Tooltip的样式不对,它仅显示纯文本。 参见下图。
我试图在这里使用此示例,但没有结果。
如何像下面的示例一样设置工具提示的样式?
这是我的代码:
约会组件
import { Component, ViewChild } from '@angular/core';
import { FullCalendarComponent } from '@fullcalendar/angular';
import { EventInput } from '@fullcalendar/core';
import dayGridPlugin from '@fullcalendar/daygrid';
import timeGrigPlugin from '@fullcalendar/timegrid';
import interactionPlugin from '@fullcalendar/interaction';
import roLocale from '@fullcalendar/core/locales/ro';
import Tooltip from 'tooltip.js'
@Component({
selector: 'app-appointment',
templateUrl: './appointment.component.html',
styleUrls: ['./appointment.component.css']
})
export class AppointmentComponent {
tooltip: Tooltip;
@ViewChild('calendar') calendarComponent: FullCalendarComponent; // the #calendar in the template
calendarLocale = roLocale;
calendarVisible = true;
calendarPlugins = [dayGridPlugin, timeGrigPlugin, interactionPlugin];
calendarWeekends = true;
calendarEvents: EventInput[] = [
{ title: 'Cod: #123124124', description: "TEXT", start: new Date(), customRender: true },
];
handleEventMouseEnter(info) {
this.tooltip = new Tooltip(info.el, {
title: info.event.title,
placement: 'top'
});
}
handleEventMouseLeave(info) {
this.tooltip.dispose();
}
}
约会.component.html
<app-navbar></app-navbar>
<full-calendar #calendar defaultView="dayGridMonth"
[header]="{left: 'prev,next today', center: 'title', right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'}"
[plugins]="calendarPlugins" [weekends]="calendarWeekends" [events]="calendarEvents" [locale]="calendarLocale"
(eventMouseEnter)="handleEventMouseEnter($event)"
(eventMouseLeave)="handleEventMouseLeave($event)"></full-calendar>
LE :CSS似乎没有适用。 我使用了示例中的CSS。
默认情况下, title元素是textElement
,没有额外的样式。 如果要设置工具提示的样式,则必须在构造函数的options参数中启用HTML的使用。
handleEventMouseEnter(info) {
this.tooltip = new Tooltip(info.el, {
html: true,
title: "<b>" + info.event.title + "</b>",
placement: 'top'
});
}
上面的代码应使工具提示文本变为粗体 。 或者, 您可以根据需要包装标题HTML样式。
这是由CSS封装问题引起的。 根据这个答案。
新增中
@Component({
selector: 'app-appointment',
templateUrl: './appointment.component.html',
styleUrls: ['./appointment.component.css'],
encapsulation: ViewEncapsulation.None
})
解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.