小编Edo*_*lga的帖子

使用 google.script.run 从 html 调用库函数

我使用 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"); 

}
Run Code Online (Sandbox Code Playgroud)

索引_libraire.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>
Run Code Online (Sandbox Code Playgroud)

这是我使用库的电子表格:Code.gs

function onopen() {
  lbrairietestedouard.ShowSideBar();
}
Run Code Online (Sandbox Code Playgroud)

Google.script.run 不会重新配置 execution_appeler_par_html() 函数。我应该使用 libraryname.execution_appeler_par_html() 但这个语法在 google.script.run 的配置中不起作用

html javascript google-apps-script

3
推荐指数
1
解决办法
1005
查看次数

标签 统计

google-apps-script ×1

html ×1

javascript ×1