mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-05 10:32:24 +03:00
791 B
791 B
Caveats
Reactive variables in template functions
Both title as meta support using template function. Due to how Vue.js determines reactivity it is not possible to use reactive variables directly in template function
{
// 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 for this to work:
{
// this will work
metaInfo() {
const locale = this.locale
return {
titleTemplate: chunk => (
locale === 'nl-NL'
? `${chunk} - Welkom`
: `${chunk} - Welcome`
)
}
}
}