Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Nuxt SEO meta tags through head property or computed property #623

Open
@rickgoemans

Description

@rickgoemans

In the Nuxt framework you can set the page's meta SEO tags by using the local settings way which is done through thehead property or ahead getter function.

This works as intended but the drawback is that I can't use any functions orthis reference to my knownledge, and this is crucial for having the page title translated using Vuei18n.

Normal non class-style components definition:

<script>export default{//...head(){return{title:this.$t('LOGIN_PAGE_TITLE'),}},</script>

I've tried to rework in 3 options that I can think off, but all give errors related to not being able to reachthis.title or something related to $t not being available:

TypeError: Cannot read properties of undefined (reading '_t')    at Vue.$t (vue-i18n.esm.js?a925:236:1)    at Vue.get (index.vue?0f48:126:1)    at Vue.get (index.vue?0f48:121:1)    at eval (vue-class-component.esm.js?2fe1:193:1)    at Array.forEach (<anonymous>)    at componentFactory (vue-class-component.esm.js?2fe1:186:1)    at eval (vue-class-component.esm.js?2fe1:311:1)    at __decorate (tslib.es6.js?9ab4:58:1)    at eval (index.vue?0f48:102:1)

Class style component

<scriptlang="ts">import{Compont, Vue}from'nuxt-propery-decorator'@Component({// OPTION 1.// head: {//     title: $t('LOGIN_PAGE_TITLE'), // Error: _t(...) not available// },// OPTION 2.// head: {//     title: this.title, // Error: this.title not available// },})exportdefaultclassLoginPageextendsVue{// OPTION 3.// get head() {//     return {//         title: this.$t('LOGIN_PAGE_TITLE'), // Error: _t(...) not available//     }// }// OPTION 4.// get head() {//    return {//        title: this.title, // Error on the computed property that _t(...) is not available//    }// }gettitle():string{returnthis.$t('LOGIN_PAGE_TITLE').toString()}</script>

Am I overlooking some basic thing or is it just not possible to achieve with class style components?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp