I'm trying to use Facebook SDK with nuxt.js referring this post post link.
But It's says window.FB is undefined.
How can i slove tis issue or is any other way to use facebook sdk in nuxt.js?
fb-sdk.js
window.fbAsyncInit = function() {
FB.init({
appId : '############',
cookie : true,
xfbml : true,
version : 'v9.0'
});
FB.AppEvents.logPageView();
};
(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 = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
method
fbLog()
{
window.FB.getLoginStatus(function (response) {
this.statusChangeCallback(response)
})
},
statusChangeCallback(response) {
console.log(response)
},
nuxt.xonfig.js
head: {
titleTemplate: '%s - test',
title: 'test',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
script: [
{ src: 'js/fb-sdk.js' }
],
},
question from:
https://stackoverflow.com/questions/65560007/use-facebook-sdk-with-nuxt-js 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…