微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将谷歌应用程序脚本文本按钮更改为填充样式

如何解决将谷歌应用程序脚本文本按钮更改为填充样式

认的文本按钮样式是 TEXT,但如果你想让它有背景,它需要是 FILLED 类型。

const textButton = CardService.newTextButton();
textButton.setText("Update Draft");
textButton.setTextButtonStyle(TextButtonStyle.FILLED);
textButton.setBackgroundColor('#d85300');

此处有问题的行是第三行,即 setTextButtonStyle 方法。 该方法采用 TextButtonStyle 类型的枚举,认值为 TEXT,但我们需要将其更改为 FILLED,以便我们可以添加背景颜色。

问题是,使用 TextButtonStyle.FILLED 应该可以,这就是您访问枚举值的方式。

这是文档的链接

https://developers.google.com/apps-script/reference/card-service/text-button#settextbuttonstyletextbuttonstyle

如果您需要更多参考,我正在创建一个 Google Workplace Gmail 插件

我正在创建一个上下文撰写界面。再次,这是文档。

https://developers.google.com/workspace/add-ons/gmail/extending-compose-ui

当我运行我的应用程序时,出现错误 ReferenceError: TextButtonStyle is not defined

我尝试了几种访问枚举的方法,它应该可以工作,但我不知道为什么不行。

解决方法

对于任何卡住的人,他们的文档对此并不明确,您需要链接方法以使其工作。这是一个工作示例。

const textButton = CardService.newTextButton()
.setText("Update Draft")
.setTextButtonStyle(CardService.TextButtonStyle.FILLED)
.setBackgroundColor('#d85300');

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。