quando1910 / nuxt3-meta-pixel

An solution for injecting Facebook pixel code in Nuxt 3
20 stars 4 forks source link

$fb instance undefined #2

Open junyongxlee opened 1 year ago

junyongxlee commented 1 year ago

I am trying to use the track function in one of the page but it is showing undefined

this.$fb.track('ViewContent') Cannot read properties of undefined (reading '$fb'

$fb.track('ViewContent') ReferenceError: $fb is not defined

quando1910 commented 1 year ago

to access $fb in nuxt3 we have to follow this

import { useNuxtApp } from '#app';
  const nuxtApp = useNuxtApp()
  console.log(nuxtApp.$fb)