Javascript Fullcalendar v4:prev按钮和浏览器后退按钮集成失败
我正在使用Fullcalendar v4,并尝试将浏览器前进/后退按钮连接到FC导航中。单击月份显示中的Javascript Fullcalendar v4:prev按钮和浏览器后退按钮集成失败,javascript,fullcalendar,html5-history,fullcalendar-4,Javascript,Fullcalendar,Html5 History,Fullcalendar 4,我正在使用Fullcalendar v4,并尝试将浏览器前进/后退按钮连接到FC导航中。单击月份显示中的prevFC按钮后,尝试使用浏览器按钮时出现问题 我尝试创建一个提琴和使用codepen,但我认为这些网站使用的包装会干扰浏览器按钮事件的某些方面。我已经设置了一个修剪下来的样本在 预期行为的一个例子是: 访问上面的链接;单击Go to calendar链接(对于测试,我需要一个启动页面来测试真实日历“主页”中的后退按钮操作) 查看日历工具栏的右上角,依次单击月份和日期按钮 使用浏览器的“后
prev
FC按钮后,尝试使用浏览器按钮时出现问题
我尝试创建一个提琴和使用codepen,但我认为这些网站使用的包装会干扰浏览器按钮事件的某些方面。我已经设置了一个修剪下来的样本在
预期行为的一个例子是:
- 访问上面的链接;单击
链接(对于测试,我需要一个启动页面来测试真实日历“主页”中的后退按钮操作)Go to calendar
- 查看日历工具栏的右上角,依次单击月份和日期按钮
- 使用浏览器的“后退/前进”按钮在视图之间移动
- 去月视图。查看日历工具栏的左上方,然后单击“
'datesRender': function (info) { if (window.history.state === null) { // // seems like when a page is first visited the history // for that page has a null state. Add a default state. const tempState = { 'view': info.view.type, 'range': { 'start': moment(info.view.activeStart) .local().format(dateFormatHuman), 'end': moment(info.view.activeEnd) .local().format(dateFormatHuman) }, 'url': window.location.href, 'comment': "INIT" }; window.history.replaceState( tempState, "INIT", window.location.href ); } else { // // if state.comment = POP then we are here after a // BACK button press. Change the comment to "dateRender". if (window.history.state.comment === "POP") { const tempState = window.history.state; tempState.comment = "datesRender"; window.history.replaceState( tempState, "From pop", window.location.href ); } else { // // there is current state and we need to change views. // add new state for the new view const state = { 'view': info.view.type, 'range': { 'start': moment(info.view.activeStart) .local().format(dateFormatHuman), 'end': moment(info.view.activeEnd) .local().format(dateFormatHuman) }, 'url': window.location.href, 'comment': "datesRender" }; window.history.pushState( state, "datesRender", window.location.href ); } } },
function handleStatePopEvent(event) { try { const tempState = window.history.state; tempState.comment = "POP"; window.history.replaceState( tempState, tempState.comment, tempState.url ); calendar.changeView( window.history.state.view, window.history.state.range ); } catch (e) { throw `handleStatePopEvent: ${e.message}`; } }