How to use vue-meta-3 useAPI outside setup function?

145 Views Asked by At

I'm attempting to use the vue-meta-3 useApi outside the setup function in order to access data associated with my component and to add it to the meta tags. According to the docs https://github.com/nuxt/vue-meta/tree/next#quick-usage this should be possible. However when I do this then the child components metadata no longer overwrites the parent component.

If I use setup functions then the child metadata does overwrite the parent but I can't access the components data in the setup function (without some hacks that Vue doesn't recommend such as using getComponentInstance).

Note I'm storing my metaManager in Vuex and I access it in the child components.

This is what I'm calling in the mount function

useMeta(
  {
    title: 'Offer',
    og: {
      description: ` is the description`,
    },
  },
  this.metaManager
);
0

There are 0 best solutions below