我在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'。
请帮帮我。
答案 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'];