Javascript 任何人都知道如何使用reactjs使用linkdIn登录 import React,{Component}来自“React”; 类LinkdIn扩展了组件{ 建造师(道具){ 超级(道具); this.onLinkedInLoad=this.onLinkedInLoad.bind(this); this.getProfileData=this.getProfileData.bind(this); this.displayProfileData=this.displayProfileData.bind(this); this.onError=this.onError.bind(this); this.onError=this.onError.bind(this); this.logout=this.logout.bind(this); } onLinkedInLoad(){ IN.Event.on(在“auth”中,getProfileData); } //使用API调用包装器请求成员的配置文件数据 getProfileData(){ IN.API.Profile(“me”) .菲尔德( “身份证”, “名字”, “姓氏”, “标题”, “地点”, “图片url”, “公共配置文件url”, “电子邮件地址” ) .result(displayProfileData) .错误(onError); } //处理API调用的成功返回 displayProfileData(数据){ var user=data.values[0]; 警报(user.emailAddress); 警报(user.pictureUrl); 警报(user.lastName); 警报(用户标题); 警报(用户、位置、名称); 警报(user.publicProfileUrl); } //处理来自API调用的错误响应 onError(错误){ console.log(错误); } //销毁linkedin的会话 注销(){ IN.User.logout(移除ProfileData); } render(){ 返回( 使用LinkdIn登录 ); } } 导出默认LinkdIn;
错误: ./src/Components/LinkdIn.js第24行:“IN”未定义Javascript 任何人都知道如何使用reactjs使用linkdIn登录 import React,{Component}来自“React”; 类LinkdIn扩展了组件{ 建造师(道具){ 超级(道具); this.onLinkedInLoad=this.onLinkedInLoad.bind(this); this.getProfileData=this.getProfileData.bind(this); this.displayProfileData=this.displayProfileData.bind(this); this.onError=this.onError.bind(this); this.onError=this.onError.bind(this); this.logout=this.logout.bind(this); } onLinkedInLoad(){ IN.Event.on(在“auth”中,getProfileData); } //使用API调用包装器请求成员的配置文件数据 getProfileData(){ IN.API.Profile(“me”) .菲尔德( “身份证”, “名字”, “姓氏”, “标题”, “地点”, “图片url”, “公共配置文件url”, “电子邮件地址” ) .result(displayProfileData) .错误(onError); } //处理API调用的成功返回 displayProfileData(数据){ var user=data.values[0]; 警报(user.emailAddress); 警报(user.pictureUrl); 警报(user.lastName); 警报(用户标题); 警报(用户、位置、名称); 警报(user.publicProfileUrl); } //处理来自API调用的错误响应 onError(错误){ console.log(错误); } //销毁linkedin的会话 注销(){ IN.User.logout(移除ProfileData); } render(){ 返回( 使用LinkdIn登录 ); } } 导出默认LinkdIn;,javascript,reactjs,Javascript,Reactjs,错误: ./src/Components/LinkdIn.js第24行:“IN”未定义 无未定义第24行:“IN”未定义无未定义 第24行:“getProfileData”未定义无未定义第31行: 未定义“IN”无未定义第31行: 未定义“displayProfileData”未定义未定义的第31行:“onError” 未定义未定义第53行:未定义“IN” 无未定义第53行:“removeProfileData”未定义无未定义 搜索关键字以了解有关每个错误的更多信息 这看起来像是林特错误。您是否
无未定义第24行:“IN”未定义无未定义
第24行:“getProfileData”未定义无未定义第31行: 未定义“IN”无未定义第31行: 未定义“displayProfileData”未定义未定义的第31行:“onError” 未定义未定义第53行:未定义“IN”
无未定义第53行:“removeProfileData”未定义无未定义 搜索关键字以了解有关每个错误的更多信息
这看起来像是林特错误。您是否将中的
作为全局变量?不,我不明白这个错误登录LinkedIn不是一个React问题,而是使用JavaScript从客户端登录。您正在尝试使用未定义的变量,这表明您需要先学习一些基础知识!你能帮我修一下这个密码吗?在这种情况下,你没办法修这个密码。
中的是什么?在.Event.on(在“auth”,getProfileData)中调用方法onlinkedLoad
和那么
中的是什么?
import React, { Component } from "react";
class LinkdIn extends Component {
constructor(props) {
super(props);
this.onLinkedInLoad = this.onLinkedInLoad.bind(this);
this.getProfileData = this.getProfileData.bind(this);
this.displayProfileData = this.displayProfileData.bind(this);
this.onError = this.onError.bind(this);
this.onError = this.onError.bind(this);
this.logout = this.logout.bind(this);
}
onLinkedInLoad() {
IN.Event.on(IN, "auth", getProfileData);
}
// Use the API call wrapper to request the member's profile data
getProfileData() {
IN.API.Profile("me")
.fields(
"id",
"first-name",
"last-name",
"headline",
"location",
"picture-url",
"public-profile-url",
"email-address"
)
.result(displayProfileData)
.error(onError);
}
// Handle the successful return from the API call
displayProfileData(data) {
var user = data.values[0];
alert(user.emailAddress);
alert(user.pictureUrl);
alert(user.lastName);
alert(user.headline);
alert(user.location.name);
alert(user.publicProfileUrl);
}
// Handle an error response from the API call
onError(error) {
console.log(error);
}
// Destroy the session of linkedin
logout() {
IN.User.logout(removeProfileData);
}
render() {
return (
<div>
<button onClick={this.onLinkedInLoad}> Login with LinkdIn </button>
</div>
);
}
}
export default LinkdIn;