我怎样才能用新功能扩展了UiApp?(How can I extend UiApp with a n

2019-09-21 22:11发布

我想在谷歌Apps脚本扩展(原型)了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);
}

谢谢

Answer 1:

这是不可能的延长了UiApp,文档,电子表格和其他高阶类。 谷歌阻止它。 如果执行该var isObject = UiApp.createApplication() instanceof Object; 线,则isObject是假的,虽然typeof UiApp.createApplication(); 表达返回object



文章来源: How can I extend UiApp with a new function?