Preparing the plugin

Note

This step is optional if you don't need SSR and Vue is available as a global variable. vue-meta will install itself in this case.

In order to use this plugin, you first need to pass it to Vue.use - if you're not rendering on the server-side, your entry file will suffice. If you are rendering on the server, then place it in a file that runs both on the server and on the client before your root instance is mounted. If you're using vue-routerPreparing the plugin - 图1, then your main router.js file is a good place:

router.js:

  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import Meta from 'vue-meta'
  4. Vue.use(Router)
  5. Vue.use(Meta)
  6. export default new Router({
  7. ...
  8. })

Options

vue-meta allows a few custom options:

  1. Vue.use(Meta, {
  2. keyName: 'metaInfo',
  3. attribute: 'data-vue-meta',
  4. ssrAttribute: 'data-vue-meta-server-rendered',
  5. tagIDKeyName: 'vmid',
  6. refreshOnceOnNavigation: true
  7. })

See the API for a description of the available plugin options