google-apps-script - 将谷歌应用脚本文本按钮更改为填充样式
问题描述
默认的文本按钮样式是 TEXT,但如果你想让它有背景,它需要是 FILLED 类型。
const textButton = CardService.newTextButton();
textButton.setText("Update Draft");
textButton.setTextButtonStyle(TextButtonStyle.FILLED);
textButton.setBackgroundColor('#d85300');
这里有问题的行是第三行,setTextButtonStyle 方法。该方法采用 TextButtonStyle 类型的枚举,默认值为 TEXT,但我们需要将其更改为 FILLED 以便我们可以添加背景颜色。
问题是,使用 TextButtonStyle.FILLED 应该可以工作,这就是您访问枚举值的方式。
这是文档的链接。
如果您想要更多参考,我正在创建一个 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');
推荐阅读
- angular - Angular HTTP POST 请求抛出 net::ERR_HTTP2_PROTOCOL_ERROR 错误
- javascript - 如何将 JSON 值发送到 FullCalendar 并在日历中显示事件
- javascript - 在不活动时运行脚本#Javascript #Android
- sql - AWS RDS Postgres:设备上没有剩余空间
- flutter - 如何在 Flutter 中更新 ListView.separated?
- html - 绝对定位的图像从相对 div 出来
- python - 我有一个包含集合的迭代器对象。我需要删除超集
- java - 删除不必要的位
- angular - 输入无效时想让边框颜色变红
- html - 如何避免表格或其他技巧将文本与 HTML 5 中的选项卡对齐?