这是我的谷歌应用脚本 html 模板的一部分:
<? if (filter == "ticket"){ var feedback = sortFeedbackByDate(getRecentTicketFeedback()); }
else if (filter == "all"){ var feedback = sortFeedbackByDate(getAllRecentFeedback()); }
else { var feedback = getRecentBomgarFeedback(); }
var percHappy = getNumHappy(feedback) / feedback.length;
var percOK = getNumOK(feedback) / feedback.length;
var percSad = getNumSad(feedback) / feedback.length; ?>
在此模板上调用 getCode() 时,此部分如下:
if (filter == "ticket"){ ;
output._ = ' <option value=\"'; output._ = ScriptApp.getService().getUrl()+"?page=1&filter=ticket" ; output._ = '\">Ticket Feedback</option>\n';
output._ = ' <option value=\"'; output._ = ScriptApp.getService().getUrl()+"?page=1" ; output._ = '\">Bomgar Feedback</option>\n';
output._ = ' <option value=\"'; output._ = ScriptApp.getService().getUrl()+"?page=1&filter=all" ; output._ = '\">All Feedback</option>\n';
output._ = ' '; } else if (filter == "all" { ;
output._ = ' <option value=\"'; output._ = ScriptApp.getService().getUrl()+"?page=1&filter=ticket" ; output._ = '\">Ticket Feedback</option>\n';
output._ = ' <option value=\"'; output._ = ScriptApp.getService().getUrl()+"?page=1&filter=all" ; output._ = '\">All Feedback</option>\n';
output._ = ' <option value=\"'; output._ = ScriptApp.getService().getUrl()+"?page=1" ; output._ = '\">Bomgar Feedback</option>\n';
output._ = ' '; } else { ;
output._ = ' <option value=\"'; output._ = ScriptApp.getService().getUrl()+"?page=1" ; output._ = '\">Bomgar Feedback</option>\n';
output._ = ' <option value=\"'; output._ = ScriptApp.getService().getUrl()+"?page=1&filter=ticket" ; output._ = '\">Ticket Feedback</option>\n';
output._ = ' <option value=\"'; output._ = ScriptApp.getService().getUrl()+"?page=1&filter=all" ; output._ = '\">All Feedback</option>\n';
output._ = ' '; } ;
如您所见,在模板中存在以下行:
else if (filter == "all"){
这被视为调用 getCode()
else if (filter == "all" {
这显然会导致语法错误。我在这里犯了某种错误,还是这是 js 代码生成中的错误?
谢谢