在工作表的 GAS 中,当用户单击 HTML 页面上的按钮时,我会执行以下函数:
function validar(){
try{
if($('#demo:checked').val()){
var demo=1;
} else {
var demo=0;
}
google.script.run.showSidebar(demo).withSuccessHandler(google.script.host.close);
} catch(e){
alert('Error: '+e.message);
}
};
变量 demo 由该页面的复选框定义(无论是否选中)。
现在,当执行上面的函数时,我收到警报:
"Error: Cannot read property withSuccessHandler of undefined".
但是服务器端函数showSidebar(demo)
仍在调用!
为什么页面没有关闭? 我该如何解决这个问题?
感谢您的帮助!
最佳答案
尝试在服务器函数名称之前链接 withSuccessHandler()
:
google.script.run
.withSuccessHandler(google.script.host.close)
.showSidebar(demo);
关于javascript - 在 Google Sheet 脚本中调用服务器端函数后关闭 HTML 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31225962/