Google App 脚本调试器无法处理 ClickHandler 回调
我已按照此处的 Google 应用脚本教程进行操作,该教程是非常简单的脚本,具有两个功能。 showDialog
(显示一个带有文本字段和提交按钮的对话框)和 respondToSubmit(e)
,它处理提交按钮并将输入的数据添加到电子表格中。 效果很好。
回调上的调试器似乎不起作用。因此,我在两个函数中都放置了一个断点并启动 showDialog
函数。调试器启动并在断点处停止执行。我单击“继续”,以便可以与新打开的对话框进行交互。但是,当我单击提交按钮时,调试器不会再次启动。执行 respondtoSubmit(e)
函数。调试器不会在断点处停止。
像这样调试回调是否有问题,或者一次只能调试一个函数?
I've followed the Google app script tutorial here which is a very simple script with two functions. showDialog
(which presents a dialog box with a text field and submit button ) and respondToSubmit(e)
which handles the submit button and adds the entered data to the spreadsheet.
It works fine.
What doesn't seem to work is the debugger on the callback. So I place a breakpoint in both functons and start the showDialog
function. The debugger kicks in and stops execution at the breakpoint. I click continue so I can interact with the newly opened dialog box. However when I click the submit button the debugger does not start again. The respondtoSubmit(e)
function is executed. The debugger just does not stop on the breakpoint(s).
Is there a problem with debugging callbacks like this or can you only debug one function at a time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
作为参考,Utilities.jsonStringify(e) 已被弃用,请改用 JSON.stringify() 和 JSON.parse()。
For reference Utilities.jsonStringify(e) is depricated, use JSON.stringify() and JSON.parse() instead.
截至目前,调试器有一些意外的行为。大多数情况下,它似乎只在脚本编辑器调用期间尊重断点,因此要调试事件处理程序,您必须从调试器而不是 UI 调用它。例如,如果您需要查看变量(例如传递给函数的事件对象),请尝试将此行添加到通常放置断点的处理程序中:
Logger.log(Utilities.jsonStringify(e));
然后执行后从脚本编辑器查看日志。
As of right now, the debugger has some unexpected behaviours. Mostly, it seems to only respect breakpoints during calls from the script editor, so to debug your event handler you must call it from the debugger, not the UI. If you need to peek into variables such as the event object passed to the function, for example, try adding this line to your handler where you'd normally put a breakpoint:
Logger.log(Utilities.jsonStringify(e));
Then view the log from the script editor after execution.
在我看来,除非从脚本编辑器运行,否则记录器也不起作用。我确实管理了
Browser.msgbox(Utilities.jsonStringify(e))
,它带来了(预期的)结果:{"parameter":{"clientY":"45","clientX":"37","eventType":"click","ctrl":"false","meta":"false","来源":"u12053277590 ","按钮":"1","alt":"假","myTextBox":"巴比","screenY":"381","screenX":"598","shift":"假", "y":"13","x":"33"}}
It seems to me that the Logger does not work either, unless run from the script editor. I did manage
Browser.msgbox(Utilities.jsonStringify(e))
which had brought the (expected) result:{"parameter":{"clientY":"45","clientX":"37","eventType":"click","ctrl":"false","meta":"false","source":"u12053277590","button":"1","alt":"false","myTextBox":"babi","screenY":"381","screenX":"598","shift":"false","y":"13","x":"33"}}