是否可以在google.script.run.withSuccessHandler返回区域



我调用一个函数(此处命名为xx1(,并希望返回一个面积变量。但它返回未定义。这是我的代码

//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;
}

为什么我无法恢复函数xx1((返回的区域?

.push是一个函数,但您使用的是索引访问。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()})

最新更新