【发布时间】:2017-05-08 02:36:41
【问题描述】:
当我尝试使用 Google 驱动器参考时,它总是显示 ReferenceError: "Drive" is not defined。 (第 16 行,文件“代码”)。
【问题讨论】:
标签: javascript google-apps-script google-drive-realtime-api
当我尝试使用 Google 驱动器参考时,它总是显示 ReferenceError: "Drive" is not defined。 (第 16 行,文件“代码”)。
【问题讨论】:
标签: javascript google-apps-script google-drive-realtime-api
除了酸的回答:
如果您有多个库,您似乎必须在每个可能使用 Drive API 的 Google Apps 脚本项目(不要与 Google Cloud 项目混淆)中启用 Drive API,即使实际调用API 出现在不同的 Apps 脚本项目中。
例如,假设您有两个 Apps 脚本项目,Util 和 DoStuffWithSheets。 Util 包含一个调用 Drive API 的函数。 DoStuffWithSheets 导入 Util(通过转到资源 -> 库)。 DoStuffWithSheets 有一个由对工作表或其他内容的编辑触发的函数,它调用使用 Drive API 的 Util 函数。
Util 中启用 Drive API 不够;它必须在 DoStuffWithSheets 中启用。
这适用于属于同一个 Google Cloud 项目的 Google Apps 脚本库,其中也启用了 Drive API。我还没有针对属于不同 GC 项目的库对其进行测试。
【讨论】: