2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-05-17 22:39:38 +03:00
Files
vue-meta/docs/guide/caveats.md
T
pimlie f71b0d866c docs: add Getting Started menuitem
docs: add section about Framework documentation
2019-04-20 10:46:06 +02:00

795 B

Caveats

Reactive variables in template functions

Both title as meta support using template function. Due to how Vue determines reactivity it is not possible to use reactive variables directly in template functions

{
  // this wont work
  metaInfo() {
    return {
      titleTemplate: chunk => (
        this.locale === 'nl-NL'
        ? `${chunk} - Welkom`
        : `${chunk} - Welcome`
      )
    }
  }
}

You need to assign the reactive variable to a local variable first for this to work:

{
  // this will work
  metaInfo() {
    const locale = this.locale
    return {
      titleTemplate: chunk => (
        locale === 'nl-NL'
        ? `${chunk} - Welkom`
        : `${chunk} - Welcome`
      )
    }
  }
}