.after 不要读取 var 值
.after don't read the var value
当我使用此代码时,即使我更改了 "seconds" 变量的值,它也总是在 1 分 20 秒时启动 "PresaTavOff" 函数,即使值是 50 秒或1秒
function doGet() {
var seconds = 10
UrlFetchApp.fetch('https://maker.ifttt.com/trigger/trigger_name_1/with/key/api');
ScriptApp.newTrigger('PresaTavOff')
.timeBased()
.after(seconds*1000)
.create();
}
function PresaTavOff(){
UrlFetchApp.fetch('https://maker.ifttt.com/trigger/trigger_name_2/with/key/api');
}
我也试过:
var seconds = parseInt(10)
代码可以工作并且可以做所有事情,只有不尊重我给它的时间的等待。
我错了什么?
谢谢
有一个 open issue for time based trigger could not fire after few seconds,已被 Google 确认并在内部报告。
虽然文档指定 time based triggers are set after x milliseconds my experience is that they never run exactly after the specified time. I've not seen any official documentation on limitations of the .after()
method, but Google do say when installing repeating time based triggers "the time may be slightly randomized"。
当我使用此代码时,即使我更改了 "seconds" 变量的值,它也总是在 1 分 20 秒时启动 "PresaTavOff" 函数,即使值是 50 秒或1秒
function doGet() {
var seconds = 10
UrlFetchApp.fetch('https://maker.ifttt.com/trigger/trigger_name_1/with/key/api');
ScriptApp.newTrigger('PresaTavOff')
.timeBased()
.after(seconds*1000)
.create();
}
function PresaTavOff(){
UrlFetchApp.fetch('https://maker.ifttt.com/trigger/trigger_name_2/with/key/api');
}
我也试过:
var seconds = parseInt(10)
代码可以工作并且可以做所有事情,只有不尊重我给它的时间的等待。 我错了什么? 谢谢
有一个 open issue for time based trigger could not fire after few seconds,已被 Google 确认并在内部报告。
虽然文档指定 time based triggers are set after x milliseconds my experience is that they never run exactly after the specified time. I've not seen any official documentation on limitations of the .after()
method, but Google do say when installing repeating time based triggers "the time may be slightly randomized"。