1

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

我使用了简单的卡片,问题是,我们需要在卡片的中心对齐操作按钮并将 css 样式应用于 TextInput

我参考了文档,但没有找到任何方法

我尝试过的以下代码,

var card = CardService.newCardBuilder();
  card.setHeader(CardService.newCardHeader().setTitle("Login Here"));
  var section = CardService.newCardSection()
  var cleint_id_Input = CardService.newTextInput()
     .setFieldName("client_id")
     .setTitle("Please enter clinet id")
  var username_Input = CardService.newTextInput()
     .setFieldName("username")
     .setTitle("Please enter username")
  var password_Input = CardService.newTextInput()
     .setFieldName("password")
     .setTitle("Please enter password")
  section.addWidget(cleint_id_Input)
  section.addWidget(username_Input)
  section.addWidget(password_Input)
  Logger.log("Input Value%s",cleint_id_Input)
  //Login action button
  var action = CardService.newAction().setFunctionName('loginCallback');
  section.addWidget(CardService.newTextButton().setText('Login').setOnClickAction(action))  
  card.addSection(section)

提前致谢

4

1 回答 1

4

截至目前,gmail 插件不支持输入小部件的完整样式。但是有一种方法可以对小部件进行少量格式化。有关更多信息,请访问:https ://developers.google.com/gmail/add-ons/concepts/widgets 。

要将按钮水平居中对齐,您可以使用以下技巧:

var whitespaces = "                        ";

section.addWidget(CardService.newTextButton().setText(whitespaces + "button" + whitespaces).setOnClickAction(action));
于 2018-02-23T08:05:03.593 回答