【问题标题】:change google apps script text button to filled style将谷歌应用脚​​本文本按钮更改为填充样式
【发布时间】:2021-05-28 11:33:19
【问题描述】:

默认的文本按钮样式是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

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

【问题讨论】:

    标签: google-apps-script enums gmail-contextual-gadgets


    【解决方案1】:

    对于任何被卡住的人,他们的文档都不清楚这一点,您需要链接方法才能使其工作。这是一个工作示例。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-20
      • 1970-01-01
      • 2012-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-10
      相关资源
      最近更新 更多