由於某種原因,從Google Apps腳本項目的服務器端返回的對象將任何成員函數替換爲null
。下面是一些示例代碼演示此:來自Google Apps腳本的服務器的對象被刪除了成員函數
server.gs
function A() {
this.a = 'a string';
this.toString = function() { return this.a; }
this.innerObj = { b : "B", toString : function(){ return 'inner object'; } }
}
function getA() { return new A(); }
clientJS.html;/*或控制檯,如果印刷原料時更喜歡... */
google.script.run.withSuccessHandler(console.log).getA();
對象,看起來是這樣的:
{ "a": "a string", "toString": null, "innerObj": { "b": "B", "toString": null } }
我能做些什麼這個?!
**更新**:我瞭解到我的代碼實際上將所有函數字符串轉換爲匿名函數。 –