问题描述
当我尝试单击为您的最新代码测试网络应用程序"时,我不断收到此错误消息.在发布"对话框中.
I keep getting this error message when I try to click "Test web app for your latest code." in the Publish dialog box.
但我还没有定义任何名为 doGet() 的函数.
But I haven't defined any function called doGet().
我的代码只有:
function unreadCount() {
var unreadNum = "Messages unread in inbox: " + GmailApp.getInboxUnreadCount();
return unreadNum
}
推荐答案
Google Apps Script 中的每个 Web 应用程序都必须有一个名为 doGet() 的主函数,它是应用程序的入口点,您的应用程序将在启动时使用该函数你输入 webapp url.
Every webapp in Google Apps Script must have a main function called doGet() which is the entry point of the app, the function that your app will start with when you type the webapp url.
对于作为独立应用程序部署并通过其 url 调用的每个应用程序都是如此——无论是否带有用户界面.
This is true for every application deployed as a standalone app and called by its url - with a user interface or not.
如果您阅读文档,您会发现 HTMLService 或 UiApp 的所有独立应用程序示例都具有 doGet 函数.
If you read the documentation you'll see that all the standalone apps examples for HTMLService or UiApp have a doGet function.
只有容器嵌入的 ui 脚本或在触发器上运行的脚本不受此规则的影响.
Only container embedded ui scripts or scripts that run on triggers are not concerned by this rule.
知道这一点,你得到的错误信息可能更有意义不是吗?
Knowing that, the error message you get is probably more meaningful isn't it ?
这篇关于找不到脚本函数:doGet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!