nuxt-community / nuxt-property-decorator

Property decorators for Nuxt (base on vue-property-decorator)
https://github.com/kaorun343/vue-property-decorator
MIT License
399 stars 34 forks source link

Access this in head #84

Closed SvenC56 closed 3 years ago

SvenC56 commented 3 years ago

Hello together

I'd like to access this in the head method to achieve something like this:

@Component({
  components: { AppSidebar, AppLoginDialog },
  asyncData({ $config }) {
    const appName: string = $config.app.name;
    const appShortName: string = $config.app.shortName;

    return {
      appName,
      appShortName,
    };
  },
  head: {
    titleTemplate: (titleChunk: string): string => {
      return titleChunk
          `${titleChunk} - ${this.appShortName || "Short"}`
          this.appName || "Title";
    },
  },
})
export default class EmptyLayout extends Vue {}

However this approach does not seem to work. Is there any other way to allow dynamic head (Besides in nuxt.config.ts)?

Thank you.

SvenC56 commented 3 years ago

I found the solution here.