【问题标题】:Run google web apps script alright in dev mode but not in exec mode在开发模式下可以正常运行谷歌网络应用程序脚本,但不能在执行模式下运行
【发布时间】:2017-11-13 00:47:42
【问题描述】:

我有一个名为 displayhtmlfromquerystring 的脚本项目,

脚本文件是

function doGet(e){
  var html;
  if(e.parameter.html)
    html=e.parameter.html;

  else
    html="Error no html";

    return HtmlService.createHtmlOutput(html+"<hr/>");
}

我已经将它部署为网络应用程序,google 给了我两个链接,一个以“dev”结尾,一个以“exec”结尾。

当使用 dev 链接运行脚本时,没问题,但是当使用 exec 链接运行时,页面显示唯一的单词“未定义”,我卡住了,谁能告诉我为什么?

我的脚本应用“https://script.google.com/macros/s/AKfycbyinAHBmjVgKDinY-bCcwQ4bgy87KuibiflG1158qRkBJSSXeMk/exec”的链接

【问题讨论】:

  • 您的代码对我有用。部署应用程序时,请确保您正在部署新版本。另外,你应该用花括号包裹你的 if/else 语句,因为应用程序脚本可能非常挑剔。
  • 对我来说显示未定义

标签: google-apps-script


【解决方案1】:

/dev 链接仅在您登录 Google 帐户时有效。

对代码进行任何更改时,您应该转到发布 > 部署为 Web 应用程序,选择一个新版本并单击更新。

现在 /exec 页面上也将提供最新的更改。

【讨论】:

  • 我明白了!部署的时候一定要选一个项目号,下次再选一个,如果选了旧号,web app还是旧的,刚才保存的脚本对你的app无效跨度>
【解决方案2】:

当我使用你的代码时它对我有用:

function doGet(e) { // main function
    var html;
  if(e.parameter.html)
    html=e.parameter.html;

  else
    html="Error no html";
    return HtmlService.createHtmlOutput(html+"<hr/>");
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-30
    • 2021-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多