[英]Is there any way to call a library from a client side user interface?
I'm building a user interface in HTML Service for Google Apps Script and I want to be able to call functions from a library that is loaded in the server side .gs file of my script.我正在为 Google Apps 脚本在 HTML 服务中构建用户界面,并且我希望能够从我脚本的服务器端 .gs 文件中加载的库中调用函数。 The client side call to the server side library does not seem to work.
客户端对服务器端库的调用似乎不起作用。 Is this possible to do?
这是可能的吗?
I'm pretty new to javascript/apps script so excuse me if I'm mis-stating what's happening here.我对 javascript/apps 脚本很陌生,所以如果我错误地说明了这里发生的事情,请原谅我。
UPDATE: Here's the solution I used更新:这是我使用的解决方案
On the container bound script:在容器绑定脚本上:
function libraryHandler(functionName){
return eval("libraryIdentifier." + functionName);
}
In the library:在图书馆:
google.script.run.libraryHandler('myLibraryFunctionName(param1,param2,etc.)')
Make a "dummy" function in the same script where the html is.在 html 所在的同一脚本中创建一个“虚拟”函数。 Make that dummy call your library function.
让那个虚拟调用你的库函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.