卡片動作,可在主機應用程式中顯示連結預覽資訊卡和智慧型方塊。如要使用連結預覽功能,您必須在指令碼中建構並傳回 Link 物件。詳情請參閱「使用智慧型方塊預覽連結」。
const decoratedText = CardService.newDecoratedText().setTopLabel('Hello').setText('Hi!'); const cardSection = CardService.newCardSection().addWidget(decoratedText); const card = CardService.newCardBuilder().addSection(cardSection).build(); return CardService.newLinkPreview().setPreviewCard(card).setTitle( 'Smart chip title');
方法
| 方法 | 傳回類型 | 簡短說明 |
|---|---|---|
print | String | 列印這個物件的 JSON 表示法。 |
set | Link | 設定連結預覽畫面中預覽資訊卡上方的顯示標題。 |
set | Link | 設定顯示第三方或非 Google 服務連結相關資訊的資訊卡。 |
set | Link | 設定連結預覽智慧型方塊中顯示的標題。 |
內容詳盡的說明文件
print Json()
列印這個物件的 JSON 表示法。這項設定僅適用於偵錯。
回攻員
String
set Link Preview Title(title)
設定連結預覽畫面中預覽資訊卡上方的顯示標題。如果未設定,連結預覽畫面會顯示 Preview 的標頭。
return CardService.newLinkPreview().setLinkPreviewTitle('Link preview title');
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
title | String | 連結預覽的標題。 |
回攻員
Link - 這個物件,用於鏈結。
set Preview Card(previewCard)
設定顯示第三方或非 Google 服務連結相關資訊的資訊卡。
const decoratedText = CardService.newDecoratedText().setTopLabel('Hello').setText('Hi!'); const cardSection = CardService.newCardSection().addWidget(decoratedText); const card = CardService.newCardBuilder().addSection(cardSection).build(); return CardService.newLinkPreview().setPreviewCard(card).setTitle( 'Smart chip title');
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
preview | Card | 預覽資訊卡。 |
回攻員
Link - 這個物件,用於鏈結。
set Title(title)
設定連結預覽智慧型方塊中顯示的標題。如未設定,智慧型方塊會顯示 Preview 的標題。
return CardService.newLinkPreview().setTitle('Smart chip title');
參數
| 名稱 | 類型 | 說明 |
|---|---|---|
title | String | 智慧型方塊的標題。 |
回攻員
Link - 這個物件,用於鏈結。