【发布时间】:2018-02-22 13:42:05
【问题描述】:
我使用 Google App Script 实现库,但在使用 google.script.run 从库中调用函数时遇到了一些困难。
这是我的图书馆的代码:
代码.gs
function ShowSideBar() {
var html = HtmlService.createTemplateFromFile('Index_librairie').evaluate()
.setTitle('Console de gestion')
.setWidth(300);
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.showSidebar(html);
}
function execution_appeler_par_html(){
Logger.log("execution_appeler_par_html");
}
Index_librairie.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script>
google.script.run.withSuccessHandler(work_off).execution_appeler_par_html();
function work_off(e){
alert(e);
}
</script>
</head>
<body>
test de ouf
</body>
</html>
这是我使用图书馆的电子表格: 代码.gs
function onopen() {
lbrairietestedouard.ShowSideBar();
}
Google.script.run 不重新编译 execution_appeler_par_html() 函数。 我应该使用 libraryname.execution_appeler_par_html() 但这种语法在 google.script.run 的配置中不起作用
【问题讨论】:
-
你是否厌倦了一个虚拟函数,它又调用
lbrairietestedouard.execution_appeler_par_html()。例如:function dummy(){ lbrairietestedouard.execution_appeler_par_html() }在您的 HTML 端只是call google.script.run.dummy()
标签: javascript html google-apps-script