Class HostAppDataSource
主机应用数据源
对于使用多选菜单的 SelectionInput
微件,请使用 Google Workspace 应用中的数据源。数据源会为多选菜单填充选择项。
const chatSpaceDataSource =
CardService.newChatSpaceDataSource().setDefaultToCurrentSpace(true);
const chatClientDataSource =
CardService.newChatClientDataSource().setSpaceDataSource(
chatSpaceDataSource);
const hostAppDataSource =
CardService.newHostAppDataSource().setChatDataSource(chatClientDataSource);
仅适用于 Google Chat 应用。不适用于 Google Workspace 插件。
详细文档
setChatDataSource(chatClientDataSource)
设置 Google Chat 中的数据源。
const chatSpaceDataSource =
CardService.newChatSpaceDataSource().setDefaultToCurrentSpace(true);
const chatClientDataSource =
CardService.newChatClientDataSource().setSpaceDataSource(
chatSpaceDataSource);
const hostAppDataSource =
CardService.newHostAppDataSource().setChatDataSource(chatClientDataSource);
仅适用于 Google Chat 应用。不适用于 Google Workspace 插件。
参数
返回
HostAppDataSource
- 此对象,用于链式调用。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-01-30。
[null,null,["最后更新时间 (UTC):2025-01-30。"],[[["`HostAppDataSource` is used for populating selection items in a multiselect menu within a Google Chat app."],["It leverages a data source from Google Chat, configured using `ChatClientDataSource` and `ChatSpaceDataSource`."],["This functionality is exclusive to Google Chat apps and is not available for Google Workspace Add-ons."],["The key method is `setChatDataSource()`, used for setting the Google Chat data source."]]],["`HostAppDataSource` provides a data source for multiselect menus in Google Chat apps, using `SelectionInput`. It's created via `CardService.newHostAppDataSource()`. `setChatDataSource()` is used to specify the data source, which must be a `ChatClientDataSource`. In turn, `ChatClientDataSource` is configured with a `ChatSpaceDataSource`. Only available for Chat apps, it sets the data source for populating selection items within the menu, and returns the current `HostAppDataSource` object.\n"]]