使用appscript开发gmail附加组件添加小部件时,是否有任何限制?

我们有一个要求,我们将添加多个部分,每个部分都带有多个小部件,我知道我们对每张卡的部分限制为100张,对开发gmail的应用程序中每张卡的小部件数量是否有任何限制?添加在。 例如: var card = CardService.newCardBuilder()     .setHeader(CardService.newCardHeader()。setTitle('Quick Label'); var section = CardService.newCardSection(); section.addWidget(CardService.newKeyValue()。setMultiline(true).setContent(“ text”))); section.addWidget(CardService.newKeyValue()。setMultiline(true).setContent(“ text”))); ......

card.addSection(section); card.addSection(section); card.addSection(section); .. enter code here

请帮助我。 谢谢

jingjie0724 回答:使用appscript开发gmail附加组件添加小部件时,是否有任何限制?

您可以添加的小部件数量确实存在限制。一张卡中最多只能有100张。

因此,如果要创建具有多个部分且每个部分具有多个小部件的卡,则必须考虑到部分和每个部分小部件的乘积不能超过100。

因此,如果只有一个部分,则可以有100个小部件。而且,如果您有100个部分,则如果希望它们全部显示,则每个部分只能有一个小部件。

您可以通过部署此加载项并相应地更改numSectionsnumWidgets来轻松检查此限制:

function buildWidgets(e) {
  var card = CardService.newCardBuilder()
  .setHeader(CardService.newCardHeader()
  .setTitle('Quick Label').setImageUrl('https://www.gstatic.com/images/icons/material/system/1x/label_googblue_48dp.png'));
  var numSections = 10; // Change this to notice limitation
  var numWidgets = 10; // Change this to notice limitation
  for (var i = 0 ; i < numSections; i++) {
    var tempsection = CardService.newCardSection().setHeader('Texts '+ i + 'aaaa.');
    for(var j = 0; j < numWidgets; j++) {      
      tempsection.addWidget(CardService.newTextButton().setText("Sections num"+j).setOnClickAction(CardService.newAction().setFunctionName("test")));  
    }
    card = card.addSection(tempsection);
  }
  card = card.build();
  return [card];
}

我不知道您为什么要这么多部分和小部件,但是请注意it's considered a Best practice是为了使卡片简单且没有太多小部件。

我希望这对您有帮助。

本文链接:https://www.f2er.com/3109466.html

大家都在问