为什么我不断定义FB。我已经按照https://stackoverflow.com/a/27724488/4414956这样的答案,但我一直无法弄清楚为什么我的FB未定义。
componentDidMount() {
window.fbAsyncInit = function() {
FB.init({
appId : appId,
cookie : true,
xfbml : true,
version : 'v2.10'
});
FB.ui(
{
method: 'share_open_graph',
action_type: 'og.shares',
display: 'popup',
action_properties: JSON.stringify({
object: {
'og:url': 'some url',
'og:image': 'some img, must be https',
'og:title': 'title',
'og:description': 'description',
}
}),
},
function(response) {
}
);
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
}
}