angular - 类型 'typeof client' 上不存在“驱动器”

标签 angular google-drive-api

Angular 5 找不到 drive来自 gapi.client .我所做的是:
package.json :

"@types/gapi.client.drive": "^3.0.0",
tsconfig.app.json :
"types": ["gapi.auth2", "gapi.client", "gapi.client.drive"]
index.html :
<script src="https://apis.google.com/js/platform.js"></script>

我的编辑器(VS Code)和 Angular 都报告如下错误:
Property 'drive' does not exist on type 'typeof client'
,但是 console.log(gapi.client.drive.files);可以得到我需要的一切。

我在这里错过了任何图书馆吗?

最佳答案

确保你安装了所有这些插件。

npm install --save @types/gapi
npm install --save @types/gapi.auth2
npm install --save @types/gapi.client.drive

并在 tsconfig.app.json
在编译器选项部分
"types": ["gapi", "gapi.auth2" ,"gapi.client", "gapi.client.drive"]

在 index.html 文件中你需要添加这个 js。
 <script src="https://apis.google.com/js/api.js"></script>

关于angular - 类型 'typeof client' 上不存在“驱动器”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48372348/

相关文章:

java - 下拉菜单中导航栏内的 RouterLink 不起作用(Angular 和 Springboot)

gmail - Google Drive使用Google Drive Viewer下载整个文件夹内容(Google Apps脚本)

google-drive-api - Google Drive Files.list : 500 error

angular - Ionic 4 - 从 Popover 传回数据而不关闭

google-drive-api - 谷歌文档 API v3 : Updating a document removes it from shared folder

javascript - 使用 Google App 脚本将多个文件上传到 Google Drive

javascript - Google 云端硬盘如何知道我安装了哪些应用程序?

angular - 如何更改从列表中选择的项目的背景颜色?

Angular fatal error : Ineffective mark-compacts near heap limit Allocation failed

javascript - 什么是angular.isFunction在angular 2中的等价物