【发布时间】:2019-12-03 06:38:49
【问题描述】:
Fullcalendar React 组件:
import FullCalendar from "@fullcalendar/react";
import timeGrid from "@fullcalendar/resource-timegrid";
import resourceDayGridPlugin from '@fullcalendar/resource-daygrid';
class FC extends React.Component {
calendarComponentRef = React.createRef();
constructor(props) {
super(props);
this.state = {
events:[{ "id": 1, "title": "event 1", "description":"some description"},......]
}
}
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"
/>
}
}
Tooltip.js 包含在标题中
<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>
在反应中完全尝试这个demo,但它在反应版本中不起作用。
但工具提示不起作用
Fullcalendar 反应示例项目sample project react fullcalendar
【问题讨论】:
-
你的函数绑定到组件了吗?
-
你能提供一个 JSfiddle 链接让我看看吗?
-
@FrankAK 完成
-
您能否制作一个最小的、可重现的示例,最好使用 CodePen 或 JSFiddle 之类的。从这里发布的少量断章取义的代码中无法判断出什么是错误的。请参阅 stackoverflow.com/help/minimal-reproducible-example 以获取有关包含内容的指导
-
首先要验证的是,
eventRender()函数是否确实在执行?您可以添加日志命令,或使用调试器查找。然后我们可以直接将其缩小到工具提示的问题
标签: reactjs fullcalendar tooltip popper.js fullcalendar-4