Caveats

Reactive variables in template functions

Corresponding issue: #322Caveats - 图1

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

  1. {
  2. // this wont work
  3. metaInfo() {
  4. return {
  5. titleTemplate: chunk => (
  6. this.locale === 'nl-NL'
  7. ? `${chunk} - Welkom`
  8. : `${chunk} - Welcome`
  9. )
  10. }
  11. }
  12. }

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

  1. {
  2. // this will work
  3. metaInfo() {
  4. const locale = this.locale
  5. return {
  6. titleTemplate: chunk => (
  7. locale === 'nl-NL'
  8. ? `${chunk} - Welkom`
  9. : `${chunk} - Welcome`
  10. )
  11. }
  12. }
  13. }

Duplicated tags after hydration with SSR

Corresponding issue: #404Caveats - 图2

Please read Multiple Vue apps support as a prerequisite

To optimize performance, VueMeta will only initialize for a Vue app when it finds a metaInfo property on any of the loaded components. That means if you render all your components by passing the component instance directly to the render function, Vue will only know of these components once the app gets mounted (see snippet below). And this means VueMeta is unable to find any metaInfo when it looks if its need to initialize in the beforeCreate hook and the appId will not be changed to the ssrAppId

  1. /* this is an example of when metaInfo will only become available once the
  2. * app is mounted and VueMeta will not correctly initialize the SSR app
  3. */
  4. const myComponent = {
  5. metaInfo: {
  6. title: 'title'
  7. }
  8. }
  9. export default App {
  10. name: 'myApp',
  11. render(h) {
  12. return h(myComponent)
  13. }
  14. };

This will result in all the metaInfo properties of your ssr app to be rendered twice, once with ssrAppId and once with appId 1.

To prevent this, either make sure there is any metaInfo configured (on any component) when the beforeCreate hook runs. Alternative (but not recommended) you could set ssrAppId to 1 as well.