数组返回空值JavaScript - google.script.run.withSuccessHandler().&l



我正在使用Google-Appscripts (JavaScript)

这里有一行代码

console.log("filldata()"+x);google.script.run.withSuccessHandler(getcolumndata).getcolumncontent(x);

getcolumncontent()在我的代码中。我的js.html文件中有getcolumndata()

我在getcolumncontent()的顶部有一个logger.log来查看X的内容,一旦它通过。X在本例中是一个包含3部分的数组,所有字符串(没有日期)。

function getcolumncontent(x){ Logger.log("x ",x); }

X返回为空白,我不知道为什么?如果有人有任何建议,请告诉我。

我有一个类似的代码行2行以上的问题行,工作没有问题-google.script.run.withSuccessHandler(setcolumndata).getcolumns(y);,其中y是一个数组,两个部分字符串,没有日期。

如有任何建议,不胜感激。

如果您的问题是无法从这段代码中看到控制台日志中x的内容:

function getcolumncontent(x){ Logger.log("x ",x); }

那么我认为这是因为你没有连接你的字符串。你应该用+来代替a,

function getcolumncontent(x){ Logger.log("x " + x); }

是否有返回值?

我不确定getcolumncontent()中是什么,但无论返回从这个函数,是传递给onSuccessHandler

例如


function one(x){
x += 1
return x // this "new" x is passed to the onSuccessHandler
}

function two(x){
Logger.log(x)
}
google.script.run.withSuccessHandler(two).one(1);

这将打印2到Apps Script控制台。

Referenece

  • 客户端服务器通信应用程序脚本

相关内容

  • 没有找到相关文章

最新更新