Class CardWithId

CardWithId

CardWithId 对象的构建器。此类是发送多张卡片时消息中卡片的唯一标识符。

仅适用于 Google Chat 应用。不适用于 Google Workspace 插件。

const cardSection = CardService.newCardSection();
cardSection.addWidget(
    CardService.newTextParagraph().setText('This is a text paragraph widget.'));

const card = CardService.newCardBuilder()
    .setHeader(CardService.newCardHeader().setTitle('Card title'))
    .addSection(cardSection)
    .build();

const cardWithId = CardService.newCardWithId()
    .setCardId('card_id')
    .setCard(card);

方法

方法返回类型简介
setCard(card)CardWithId设置 cardWithId 的卡片。
setCardId(id)CardWithId设置 cardWithId 的唯一卡 ID。

详细文档

setCard(card)

设置 cardWithId 的卡片。

const cardHeader = CardService.newCardHeader()
    .setTitle('Card Header Title')
    .setSubtitle('Card Header Subtitle');

const card = CardService.newCardBuilder()
    .setHeader(cardHeader)
    .build();

const cardWithId = CardService.newCardWithId()
    .setCard(card);

参数

名称类型说明
cardCard要使用的 Card

弃踢回攻

CardWithId - 此对象,用于链接。


setCardId(id)

设置 cardWithId 的唯一卡 ID。

const cardWithId = CardService.newCardWithId();

// Sets the card ID of the cardWithId.
cardWithId.setCardId('card_id');

参数

名称类型说明
idString要使用的文本。

弃踢回攻

CardWithId - 此对象,用于链接。