Class Suggestions
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
建議自動完成建議,用於補充 TextInput
小工具。
適用於 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
:這個物件用於鏈結。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間: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."]]