Ionic 3 Native - LinkedIn登录错误

时间:2017-07-26 09:12:56

标签: ionic-framework ionic2 ionic3 ionic-native

我在Ionic 3应用程序中使用了ionic native linkedin插件。

我的代码:

var scopes = ['r_basicprofile', 'r_emailaddress', 'rw_company_admin', 'w_share'];
this.linkedin.login(scopes, true).then((res) => {
    console.log(res) ;
}, (err) => {
    console.log(err) ;
});

我有错误:

  

类型'string []'的参数不能分配给类型的参数   'LinkedInLoginScopes []'。类型'字符串'不能分配给类型   'LinkedInLoginScopes'。

请帮帮我。

2 个答案:

答案 0 :(得分:6)

您需要定义scopes的类型。

插件包装器中的scopes参数类型 -

  

导出类型LinkedInLoginScopes =' r_basicprofile' | ' r_emailaddress'   | ' rw_company_admin' | ' w_share&#39 ;;

     

登录(范围:LinkedInLoginScopes [],promptToInstall:boolean):   承诺{返回; }

let scopes:any = ['r_basicprofile', 'r_emailaddress', 'rw_company_admin', 'w_share'];

 let scopes:Array<string> = ['r_basicprofile', 'r_emailaddress', 'rw_company_admin', 'w_share'];


    this.linkedin.login(scopes, true).then((res) => {
        console.log(res) ;
    }, (err) => {
        console.log(err) ;
    });

答案 1 :(得分:0)

按如下方式定义:

scopes: LinkedInLoginScopes[] = ['r_basicprofile', 'r_emailaddress', 'rw_company_admin', 'w_share'];