-1

我已经使用谷歌脚本创建了简单的 gmail 插件,因为我在这里遇到了困难,

当我们单击锚标记时如何在锚中使用 onclick 方法我们需要执行一些操作,我检查了文档,我找不到任何方法我尝试过以下代码,

section.addWidget(CardService.newTextParagraph().setText('<a href="" onclick="notificationCallback">TestLink</a>'))

提前致谢

4

2 回答 2

1

似乎<a>不能用于 gmail 插件。可以使用部分用于装饰字符串的标签。例如,有<b><u>。因此,作为一种解决方法,如何使用它?

从 :

section.addWidget(CardService.newTextParagraph().setText('<a href="" onclick="notificationCallback">TestLink</a>'))

至 :

section.addWidget(CardService.newTextButton().setText('TestLink').setOnClickAction(notificationCallback))

如果我误解了你的问题,我很抱歉。

编辑 :

既然找到了,就在这里添加。

基本 HTML 格式:https ://developers.google.com/gmail/add-ons/concepts/widgets#text_formatting 。

于 2018-02-09T07:05:25.767 回答
0

您可以简单地执行以下操作

var exampleCard = CardService.newCardBuilder();
var section=CardService.newCardSection().setHeader("Google Services");
section.addWidget(CardService.newKeyValue()
                .setContent("<a href=https://www.google.com/>google</a>"));
exampleCard.addSection(section);
return [exampleCard.build()];
于 2018-04-19T18:54:38.253 回答