Defining metaInfo

You can define a [keyName] property in any of your components, by default this is metaInfo.

See the API for a list of recognised metaInfo properties

Note

Altough we talk about the metaInfo variable on this page, please note that the keyName is configurable and could be different in your case. E.g. Nuxt.jsDefining metaInfo - 图1 uses head as keyName

App.vue:

  1. <template>
  2. <div id="app">
  3. <router-view></router-view>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. name: 'App',
  9. metaInfo: {
  10. // if no subcomponents specify a metaInfo.title, this title will be used
  11. title: 'Default Title',
  12. // all titles will be injected into this template
  13. titleTemplate: '%s | My Awesome Webapp'
  14. }
  15. }
  16. </script>

Home.vue

  1. <template>
  2. <div id="page">
  3. <h1>Home Page</h1>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. name: 'Home',
  9. metaInfo: {
  10. title: 'My Awesome Webapp',
  11. // override the parent template and just use the above title only
  12. titleTemplate: null
  13. }
  14. }
  15. </script>

About.vue

  1. <template>
  2. <div id="page">
  3. <h1>About Page</h1>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. name: 'About',
  9. metaInfo: {
  10. // title will be injected into parent titleTemplate
  11. title: 'About Us'
  12. }
  13. }
  14. </script>