Plugin methods

The vue-meta plugin injects a $meta() function in the Vue prototype which provides the following methods

Note

$meta() is a function so we only need to insert it once in the Vue.prototype, but still use this to reference the component it was called from

$meta().getOptions

  • returns pluginOptionsCould be used by third-party libraries who wish to interact with vue-meta

$meta().refresh

  • returns metaInfoUpdates the current metadata with new metadata.Useful when updating metadata as the result of an asynchronous action that resolves after the initial render takes place.

$meta().inject

SSR only

inject is available in the server plugin only and is not available on the client

It returns a special metaInfo object where all keys have an object as value which contains a text() method for returning html code

See Rendering with renderToString for an example

Passing arguments to text()

In some cases you can pass an argument to the text method. E.g. to automatically add the ssrAttribute on ssr or render properties in the body

$meta().pause

  • arguments:
    • refresh (type boolean, default false)
  • returns resume()Pauses global metadata updates until either the returned resume method is called or resume

$meta().resume

  • arguments:
    • refresh (type boolean, default false)
  • returns metaInfo (optional)Resumes metadata updates after they have been paused. If refresh is true it immediately initiates a metadata update by calling refresh