0

https://qiita.com/munieru_jp/items/d7e9f98b5ab5960e7a93

If you do as above, you can get the contents of {{$ t ('HELLO_WORLD')}} in the <template> tag. How can I get {{$ t ('HELLO_WORLD')}} in the <script> tag in the same file?

The reason is that I want to manage title descriptions and og related items with head.

We apologize for the inconvenience, but we would appreciate it if you could teach us. Then thank you.

2 Answers2

3

You have access to the nuxt-i18n translation helper in the script of your page with this.$t and the head method on the other hand has access to the this context. So you could do something like this:

export default {
    head () {
        return {
            title: this.$t('HELLO_WORLD')
        }
    }
}
micbra
  • 73
  • 6
0

Use the head method to set the HTML Head tags for the current page.

https://nuxtjs.org/api/pages-head/

Mulhoon
  • 1,852
  • 21
  • 26