我想用包装功能在Google Apps脚本中扩展(原型)UiApp,但运行下面的简单示例时出现TypeError ... 我做错了什么?如何用新功能扩展UiApp?
Object.prototype.addLabel = function(text) {
this.createLabel(text);
return this;
}
function testingxUiApp() {
var doc = SpreadsheetApp.getActiveSpreadsheet();
var app = UiApp.createApplication().setTitle('playing around UiApp').setHeight("250");
var panel = app.createFlowPanel().setId('panel');
app.add(panel);
panel.add(app.addLabel("adding label for testing"));
doc.show(app);
}
感谢
伟大的问题! {一般问题,所以不仅仅是UiApp,而是任何GAS的Google课程}我在http://stackoverflow.com/questions/17432951/how-to-extend-google-apps-script-class/30539765#30539765,其中包括对此答案的引用,以及我遇到的所有其他答案;所以,如果这可以帮助你,我建议在那里看到我的答案。 –
我投票结束这个问题作为题外话,因为类UiApp已弃用。参考https://developers.google.com/apps-script/reference/ui/ui-app –