[英]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.