的解决方案是非常简单的。发现困难的方式 - 试验和错误。
HTML:
<a href="#" on-click="fb_login">Sign in with facebook</a>
聚合物脚本:
Polymer ({
is: 'facebook-login',
fb_login: function() {
FB.login(function(response) {
FB.api('/me', function(facebookResponse) {
/* Do something here*/
});
}, { scope: 'public_profile,email,user_birthday' });
},
ready: function() {
window.fbAsyncInit = function() {
FB.init({
appId: 'YOUR_APP_ID',
cookie : true,
xfbml: true,
version: 'v2.3'
});
};
if(typeof(FB) == 'undefined') {
(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'));
}
},
});