Class Suggestions
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
建议
用于补充 TextInput
widget 的自动补全建议。
适用于 Google Workspace 插件和 Google Chat 应用。
const textInput = CardService.newTextInput().setSuggestions(
CardService.newSuggestions()
.addSuggestion('First suggestion')
.addSuggestion('Second suggestion'),
);
详细文档
addSuggestion(suggestion)
添加文本建议。
参数
名称 | 类型 | 说明 |
suggestion | String | 建议文字。 |
返回
Suggestions
- 此对象,用于链式调用。
addSuggestions(suggestions)
添加文本建议列表。
参数
名称 | 类型 | 说明 |
suggestions | Object[] | 字符串建议数组。 |
返回
Suggestions
- 此对象,用于链式调用。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eAutocomplete suggestions enhance TextInput widgets in Google Workspace Add-ons and Google Chat apps by providing users with pre-filled options.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can easily add single or multiple text suggestions using the \u003ccode\u003eaddSuggestion()\u003c/code\u003e and \u003ccode\u003eaddSuggestions()\u003c/code\u003e methods respectively, within the Suggestions object.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eaddSuggestion()\u003c/code\u003e method takes a single string argument representing the suggestion text, while \u003ccode\u003eaddSuggestions()\u003c/code\u003e accepts an array of strings for multiple suggestions.\u003c/p\u003e\n"],["\u003cp\u003eBoth methods return the Suggestions object, allowing for method chaining to efficiently build a comprehensive list of suggestions.\u003c/p\u003e\n"]]],[],null,["# Class Suggestions\n\nSuggestions\n\nAutocomplete suggestions to supplement a [TextInput](/apps-script/reference/card-service/text-input) widget.\n\nAvailable for Google Workspace add-ons and Google Chat apps.\n\n```javascript\nconst textInput = CardService.newTextInput().setSuggestions(\n CardService.newSuggestions()\n .addSuggestion('First suggestion')\n .addSuggestion('Second suggestion'),\n);\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|--------------------------------------------------------|------------------|---------------------------------|\n| [addSuggestion(suggestion)](#addSuggestion(String)) | [Suggestions](#) | Add a text suggestion. |\n| [addSuggestions(suggestions)](#addSuggestions(Object)) | [Suggestions](#) | Add a list of text suggestions. |\n\nDetailed documentation\n----------------------\n\n### `add``Suggestion(suggestion)`\n\nAdd a text suggestion.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------------|----------|----------------------|\n| `suggestion` | `String` | The suggestion text. |\n\n#### Return\n\n\n[Suggestions](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `add``Suggestions(suggestions)`\n\nAdd a list of text suggestions.\n\n#### Parameters\n\n| Name | Type | Description |\n|---------------|------------|---------------------------------|\n| `suggestions` | `Object[]` | An array of string suggestions. |\n\n#### Return\n\n\n[Suggestions](#) --- This object, for chaining."]]