首页 文章

GooglePlus类没有Ionic应用程序中Cordova插件的登录功能

提问于
浏览
0

我正在尝试按照this tutorial在Ionic应用程序中使用GooglePlus登录 . 我已经安装了Eddy Verbruggen的插件,根据教程,我应该在 home.ts 的顶部有这一行 .

import { GooglePlus } from 'ionic-native';

当我尝试构建时,Ionic抱怨了 . 改变它有帮助

import { GooglePlus } from '@ionic-native/google-plus';

但是现在以下代码不会透露

GooglePlus.login({.....

因为"Property 'login' does not exist on type 'typeof GooglePlus'" . 使用WebStorm我可以控制点击GooglePlus,它会带我到 node_modules/@ionic-native/google-plus 中的类定义,它表明该类显然有一个名为login的函数 .

enter image description here

  • npm 5.5.1

  • 离子3.19.0

  • Cordova 7.1.0

  • OS X 10.12.6

1 回答

  • 1

    我在教程中需要的这些更改部分详见Ionic's docs

    1)将GooglePlus添加到构造函数中

    constructor(private googlePlus: GooglePlus) { }
    

    2)将 GooglePlus.login() 更改为 this.googlePlus.login

    3)导入GooglePlus并在 app.module.ts 中将其添加为提供商

    import { GooglePlus } from '@ionic-native/google-plus';
    

    ...

    providers: [
        GooglePlus
    ]
    

相关问题