在googlescript中添加到卡片时,部分是否有最大数量

在googlescript中添加到卡片时,部分是否有最大数量?

我的卡片中有 13 个部分,但仅显示 12 个部分,向卡片中添加部分是否有具体限制

我有多个部分要动态添加到卡中,是否可以在卡中添加 n 个部分?

zhuo67760212 回答:在googlescript中添加到卡片时,部分是否有最大数量

是的,截至目前,一张卡最多可包含100个部分。

但是,13个项目不是问题。您面临的问题在代码的其他地方。没有这些信息,我们将无能为力。

作为证明,下面的代码成功地展示了如何添加15个小部件:

function buildAddOn(e) {
  var tempsections = [];
  for (var i =0 ; i<15; i++) {
    var tempsection = CardService.newCardSection().setHeader('Texts '+ i + 'aaaa.');
    tempsection.addWidget(CardService.newTextButton().setText("Sections num"+i).setOnClickAction(CardService.newAction().setFunctionName("test")));
    tempsections.push(tempsection);
  }

  // Build the main card after adding the section.
  var card = CardService.newCardBuilder()
    .setHeader(CardService.newCardHeader()
    .setTitle('Quick Label')
    .setImageUrl('https://www.gstatic.com/images/icons/material/system/1x/label_googblue_48dp.png'))
    .addSection(tempsections[0])
    .addSection(tempsections[1])
    .addSection(tempsections[2])
    .addSection(tempsections[3])
    .addSection(tempsections[4])
    .addSection(tempsections[5])
    .addSection(tempsections[6])
    .addSection(tempsections[7])
    .addSection(tempsections[8])
    .addSection(tempsections[9])
    .addSection(tempsections[10])
    .addSection(tempsections[11])
    .addSection(tempsections[12])
    .addSection(tempsections[13])
    .addSection(tempsections[14])
    .build();

  return [card];
} 

function test() {
  return 0;
}

为证明起见,这是添加101个部分的更改:

function buildAddOn(e) {
  var tempsections = [];
  for (var i =0 ; i<101; i++) {
    var tempsection = CardService.newCardSection().setHeader('Texts '+ i + 'aaaa.');
    tempsection.addWidget(CardService.newTextButton().setText("Sections num"+i).setOnClickAction(CardService.newAction().setFunctionName("test")));
    tempsections.push(tempsection);
  }

  // Build the main card after adding the section.
  var card = CardService.newCardBuilder()
    .setHeader(CardService.newCardHeader()
    .setTitle('Quick Label')
    .setImageUrl('https://www.gstatic.com/images/icons/material/system/1x/label_googblue_48dp.png'));
  for (var i =0 ; i<101; i++) {
    card = card.addSections(tempsections[i]);
  }
  card = card.build();

  return [card];
} 
本文链接:https://www.f2er.com/3117364.html

大家都在问