如何将两个数组的值获取到相同的html javascript
我在谷歌应用程序脚本中有两个函数 代码G.gs:如何将两个数组的值获取到相同的html javascript,javascript,arrays,google-apps-script,Javascript,Arrays,Google Apps Script,我在谷歌应用程序脚本中有两个函数 代码G.gs: function getdata1(e) { // works.. return array_1; } function getdata2(e) { // works.. return array_2; } index.html: function getData1(e) { google.script.run.withSuccessHandler(dispData1).getData1(e); } function dispD
function getdata1(e) {
// works..
return array_1;
}
function getdata2(e) {
// works..
return array_2;
}
index.html:
function getData1(e) {
google.script.run.withSuccessHandler(dispData1).getData1(e);
}
function dispData1(array_1) {
// here i can acces the value of array_1.
// NOW i need to access the values of array_2 from the other function (getData2)
}
感谢您的帮助添加一个名为getAllData()的中间函数 然后从html调用getAllData
//.html file
function getAllData(e) {
google.script.run.withSuccessHandler(dispData).getAllData(e);
}
function dispData(response) {
var array_1 = response.array_1
var array_2 = response.array_2
}
要同时运行这两个功能,请使用:
//.html file
function getAllData(e) {
google.script.run.withSuccessHandler(dispData).getAllData(e);
}
function dispData(response) {
var array_1 = response.array_1
var array_2 = response.array_2
}
const gsr = func =>
new Promise(res => google.script.run.withSuccessHandler(res)[func]());
Promise.all(['getdata1', 'getdata2'].map(f => gsr(f))).then(
([arr1, arr2]) => {
console.log({ arr1, arr2 });
}
);