全日历React组件:
<script src="https://unpkg.com/popper.js/dist/umd/popper.min.js"></script>
<script rc="https://unpkg.com/tooltip.js/dist/umd/tooltip.min.js">/script>
标头中包含Tooltip.js
{{1}}
已在React中完全尝试此demo,但在React版本中不起作用。
但是工具提示不起作用
全日历反应示例项目sample project react fullcalendar
答案 0 :(得分:1)
使用Tooltip.js
的工具提示
eventRender(info){
var tooltip = new Tooltip(info.el, {
title: info.event.extendedProps.description,
placement: 'top',
trigger: 'hover',
container: 'body'
});
}
在组件中:
render() {
return <FullCalendar
events={this.state.getEvents}
defaultView="resourceTimeGridDay"
plugins={[timeGrid, interactionPlugin, resourceDayGridPlugin]}
eventRender={this.eventRender}
schedulerLicenseKey="GPL-My-Project-Is-Open-Source"
/>
}
OR
import ReactTooltip from 'react-tooltip'
和处理eventPosition
handleEventPositioned(info) {
info.el.setAttribute("data-tip","some text tip");
ReactTooltip.rebuild();
}
和
render() {
return <FullCalendar
events={this.state.getEvents}
defaultView="resourceTimeGridDay"
plugins={[timeGrid, interactionPlugin, resourceDayGridPlugin]}
eventPositioned={this.handleEventPositioned}
schedulerLicenseKey="GPL-My-Project-Is-Open-Source"
/>
}
答案 1 :(得分:1)
使用content injection hook,例如为Material-ui tooltip:
eventContent: ( arg ) => {
return (
<Tooltip title={ <Typography color="inherit">Tooltip with HTML</Typography> } arrow>
{ renderInnerContent( arg ) }
</Tooltip>
);
}
如果要具有与默认内容完全相同的内容,请从全日历源复制功能:
/**
* https://github.com/fullcalendar/fullcalendar/blob/495d925436e533db2fd591e09a0c887adca77053/packages/common/src/common/StandardEvent.tsx#L79
*/
function renderInnerContent( innerProps ) {
return (
<div className='fc-event-main-frame'>
{ innerProps.timeText &&
<div className='fc-event-time'>{ innerProps.timeText }</div>
}
<div className='fc-event-title-container'>
<div className='fc-event-title fc-sticky'>
{ innerProps.event.title || <Fragment> </Fragment> }
</div>
</div>
</div>
);
}
要将ListView
内容与默认内容区分开,可以使用以下代码(给定Calendar reference calendarRef):
eventContent: ( arg ) => {
const data = calendarRef.current.getApi().getCurrentData();
const viewSpec = data.viewSpecs[arg.view.type];
let innerContent;
if (viewSpec.component.name === 'ListView') {
/**
* https://github.com/fullcalendar/fullcalendar/blob/495d925436e533db2fd591e09a0c887adca77053/packages/list/src/ListViewEventRow.tsx#L55
*/
innerContent = renderListInnerContent( arg );
} else {
innerContent = renderInnerContent( arg );
}
return ( <Tooltip ... >{ innerContent }</Tooltip>);
};
答案 2 :(得分:0)
使用 tippy 和 eventMouseEnter 的工具提示
handleMouseEnter = (arg) =>{
tippy(arg.el, {
content: "my tooltip!"
});
}
在组件中
render() {
return (
<FullCalendar ref={this.calendarRef}
plugins={[dayGridPlugin, interactionPlugin]}
initialView="dayGridMonth"
weekends={true}
eventMouseEnter={this.handleMouseEnter}
/>
)
}