我有一个示例代码:
window.fbAsyncInit = function() {
FB.init({appId: appId, status: true, cookie: true, xfbml: true});
this.test();
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
this.test = function() {
alert('test');
}
当我在 FB init 上调用函数test()
时结果是“ TypeError: this.test is not a function
”,如何解决?