简体   繁体   English

google.script.run.withSuccessHandler 可以返回区域吗?

[英]Can google.script.run.withSuccessHandler return area?

i call a function (named here xx1) and i want to return an area variable.我打电话给 function(这里命名为 xx1),我想返回一个区域变量。 But it return undefined.但它返回未定义。 Here is my code这是我的代码

//in html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<form>
<input id="e1" name="e1" value="aaa">
<input id="e2" name="e2" value="aaa">
<input id="e3" name="e3" value="aaa">
</form>

<script>

function bb(ff){
document.getElementById("e1").value=ff["e1"];
document.getElementById("e2").value=ff["e2"];
document.getElementById("e3").value=ff["e3"];
M.updateTextFields();
}

google.script.run.withSuccessHandler(bb)
      .xx1();
</script>
</body>
</html>

//in code.gs
function xx1(){
var pp=[];
var obj={};
obj.e1="e1 hh";
obj.e2="e2 hh";
obj.e3="e2 hh";
pp.push[obj];
return pp;
}

Why i can't recover the area returned by the function xx1()?为什么我无法恢复 function xx1() 返回的区域?

.push is a function but you are using index access. .push是 function 但您正在使用索引访问。 pp.push[obj]; should be pp.push(obj)应该是pp.push(obj)

 const x1 = () => { var pp=[]; var obj={}; obj.e1="e1 hh"; obj.e2="e2 hh"; obj.e3="e2 hh"; pp.push[obj]; return pp; } const x2 = () => { var pp=[]; var obj={}; obj.e1="e1 hh"; obj.e2="e2 hh"; obj.e3="e2 hh"; pp.push(obj); return pp; } console.log ({x1: x1(), x2: x2()})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 google.script.run.withSuccessHandler 不返回值 - google.script.run.withSuccessHandler does not return value Google Apps脚本google.script.run.withSuccessHandler失败 - Google Apps Script google.script.run.withSuccessHandler failing google.script.run.withSuccessHandler(function) 不返回数据 - google.script.run.withSuccessHandler(function) not returning data google.script.run.withSuccessHandler(onSuccess)。 onSuccess在构造函数中不起作用 - google.script.run.withSuccessHandler(onSuccess). onSuccess doesn't works inside constructor 有什么方法可以简化 google.script.run.withSuccessHandler 中来自 code.gs 的各种函数调用吗? Google Apps 脚本 - Is there any way to simplify various function calls from code.gs in a google.script.run.withSuccessHandler? Google Apps Script 如何结合谷歌应用程序脚本processForm,withSuccessHandler和withUserObject - how to combine google app script processForm, withSuccessHandler and withUserObject 如何使用 withSuccessHandler 正确返回值 - How to return values correctly using withSuccessHandler 无法在Google脚本中返回2D数组? - Can not return 2D Array in Google Script? 如果满足条件,如何运行 2 google.script.run? - How can I run 2 google.script.run if condition is met? 如何在Google Apps脚本中异步运行方法? - How can I run a method asynchronously in Google Apps Script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM