Javascript 是否有更新全局变量的限制?谷歌应用程序脚本到电报机器人
当前我的代码可以运行到currentstep='2'。我已经在我的调查(数据)中更新了currentstep='3',它将能够执行我的xD(数据)。但是,代码没有更新为“3”才能运行Javascript 是否有更新全局变量的限制?谷歌应用程序脚本到电报机器人,javascript,google-apps-script,telegram-bot,Javascript,Google Apps Script,Telegram Bot,当前我的代码可以运行到currentstep='2'。我已经在我的调查(数据)中更新了currentstep='3',它将能够执行我的xD(数据)。但是,代码没有更新为“3”才能运行 function check_command(data){ var text = data.message.text; if(text == "/start" || text == "/start"){ currentstep = '1'; re
function check_command(data){
var text = data.message.text;
if(text == "/start" || text == "/start"){
currentstep = '1';
return;
}
if (text == "/survey" || text == "/survey"){
currentstep = '2';
return;
}
return;
}
function process_loop(data){
if(currentstep == "1"){
start(data);
return;
}
if(currentstep == "2"){
survey(data);
return;
}
if(currentstep == "3"){
xD(data);
return;
}
}
function doPost(e){
var data = JSON.parse(e.postData.contents);
check_command(data);
process_loop(data);
}
根据您的代码,您提到您正在
调查(数据)
中设置currentstep='3'
无论何时收到doPost(),您都会在检查命令(数据)
中将当前步骤设置为1或2。然后它将调用process\u循环(数据)
。如果当前步骤最初为2,则在测量(数据)
中将其设置为3。但是,由于包含了return
语句,它将退出过程循环(数据)
。因此,将不执行xD(数据)
您可以决定是仅删除(currentstep==“2”)中的return
语句,还是在每个条件下删除它们。请提供。请注意,您提供的示例必须允许我们重现问题。它不必是您的实际代码。这是一个帮助我们帮助你的例子。