2

in vue-meta version 3 I use metaInfo Like vue-meta version 2

I import vue-meta plugin but I can't access to component, error is "this is undefined"

in setup() we just access to props and context

How can I create Dynamic meta via api call and which way is a standard way

vue-meta version 3 documentation

my app.js

import { createApp } from 'vue'
import Axios from 'axios'
import { createMetaManager, plugin as metaPlugin } from 'vue-meta'

const app = createApp({
    components: {
        ...
    }
})
app.use(createMetaManager())
app.use(metaPlugin)

my component

export default {
  data: function () {
    return {
      productName: '',
    };
  },
  mounted() {
      axios.post('/get_product_name').then((response)=>{
          this.productName = response.data.product_name
      })
  },
  metaInfo() {
    let productName = this.productName; 
    return {
       title: productName ?  "product : " + productName : "product",
    }
  }
}
MA Deldari
  • 331
  • 2
  • 10

0 Answers0