You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Google Card Service中实现密码输入框功能?

在Google Card Service中实现密码类型输入框

Google Card Service的TextInput组件原生支持密码输入功能,只需调用其setPasswordInput(true)方法,即可将输入框设置为密码类型,输入内容会自动以星号(*)隐藏。

示例代码

function buildPasswordFormCard() {
  // 创建卡片构建器
  const cardBuilder = CardService.newCardBuilder();

  // 创建密码输入框组件
  const passwordInput = CardService.newTextInput()
    .setFieldName("user_password") // 设置字段名,用于后续获取输入值
    .setTitle("密码") // 输入框标题
    .setPasswordInput(true); // 启用密码隐藏模式

  // 将输入框添加到卡片分区
  const cardSection = CardService.newCardSection().addWidget(passwordInput);
  cardBuilder.addSection(cardSection);

  return cardBuilder.build();
}

调用上述函数生成的卡片中,密码输入框会自动隐藏输入内容,达到你期望的星号掩码效果。

内容的提问来源于stack exchange,提问作者Poojan3037

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 23:29:50