google-chrome - 如何修复“未检查的 runtime.lastError:消息端口在收到响应之前关闭。” 链接到 G-Cal 事件时?
问题描述
我正在尝试生成一个链接,将用户直接带到所选的 Google 日历事件。
我生成的链接与您在通过日历界面时到达的链接相同,但是,当用户选择该链接时,它会加载一个带有 Google 日历标题和 Keep/Tasks 侧边栏的空白页面。没有加载任何实际内容,我Unchecked runtime.lastError: The message port closed before a response was received.
在控制台中收到错误。这是下面的代码,但正如我所说 - 链接是相同的。
var events = [];
var today = new Date;
var myEvents = CalendarApp.getDefaultCalendar().getEventsForDay(today);
var calendarId = CalendarApp.getDefaultCalendar().getId();
myEvents.forEach(function(event){
var eventIdSplit = event.getId().split('@');
var newRecord = app.models.Calendar.newRecord();
newRecord.Date = event.getStartTime();
newRecord.Title = event.getTitle();
newRecord.Description = event.getDescription();
newRecord.calendarLink = 'https://calendar.google.com/calendar/r/eventedit/' + (Utilities.base64EncodeWebSafe(eventIdSplit[0] + " " + calendarId));
events.push(newRecord);
});
我搜索了错误,发现其他用户建议禁用所有扩展,但是,我没有运行任何扩展。
解决方案
我发现
newRecord.calendarLink = 'https://calendar.google.com/calendar/r/eventedit/' + (Utilities.base64EncodeWebSafe(eventIdSplit[0] + " " + calendarId));
'=='
在日历链接的末尾生成几个。这些等号是中断的原因。
因此,将上面的代码编辑到下面可以解决这个问题:
newRecord.calendarLink = 'https://calendar.google.com/calendar/r/eventedit/' + (Utilities.base64EncodeWebSafe(eventIdSplit[0] + " " + calendarId)).replace(/=/g, "");
推荐阅读
- python - ELI5:什么是 Django?
- c# - 如何在c#中查找或计算多维数组中的重复项
- android - 在查询中使用 get() 和 exists() 规则获取缺少或不足的权限
- javascript - 可以为网格区域属性设置动画吗?
- linux - 如何编写 git 命令来分隔历史文件?
- reactjs - 解决 axios 请求后组件状态未更新
- git - 致命:不支持协议“https”
- ios - 更新 GoogleMaps 和 GooglePlaces pod 后 iOS 在发布时崩溃
- php - 基于 PDO 数组对象生成字段集组
- akka - 如果 akka 演员由于某种原因出现故障,如何恢复消息?