我想用包裝功能在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 –