我正在尝试初始化 JavaScript SDK 以最终使用 Facebook Graph API。但它一直在说Cannot find name FB
,不知道为什么。这是我所做的,
componentDidMount() {
(window as any).fbAsyncInit = function() {
FB.init({ // this FB errors out
appId : "my-app-id",
autoLogAppEvents : true,
xfbml : true,
version : "v2.11"
});
};
(function(d: any, s: any, id: any) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return; }
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "facebook-jssdk"));
}
PS我正在使用TSLint
,这就是为什么我拥有所有这些typedef any