问题描述
如何让.getStartTime工作?
我正在使用CalendarEvent类,并且.getStartTime列在此类下( https://developers.google.com/apps-script/reference/calendar/calendar-event#getStartTime())
但是当我尝试运行以下代码时,我得到了TypeError: Cannot find function getStartTime in object CalendarEvent.
how do i get .getStartTime to work?
i'm using the CalendarEvent class, and .getStartTime is listed under this class (https://developers.google.com/apps-script/reference/calendar/calendar-event#getStartTime())
but when i try to run the following code, i get TypeError: Cannot find function getStartTime in object CalendarEvent.
function test() {
var TA =CalendarApp.getCalendarsByName("CalendarName")[0].getEvents(startDt, endDt);
var starting = TA.getStartTime();
Logger.log(starting);
return;
};
我在做什么错?我想不通,我在网上找到的所有教程都表明应该可以.
what am i doing wrong? i can't figure it out, all the tutorials i found online indicates that this should work.
推荐答案
查看 getEvents(Date,Date)会返回CalendarEvent [].
Looking at getEvents(Date,Date) it returns CalendarEvent[] .
因此,您试图在整个数组上而不是特定的CalendarEvent对象上调用方法.
So , you're trying to call a method on an entire array, instead of a particular CalendarEvent object.
只需使用TA[0].getStartTime()
或您想要的任何事件.
Simply use TA[0].getStartTime()
or whichever event you'd like.
这篇关于.getStartTime()不是函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!