Like all other Vue plugins, you can install Vue Meta and hook it up to your Vue app with the following steps:
- Install Vue Meta via npm:
$ npm i vue-meta
Alternatively, you can install it via CDN with an <script> element, as follows:
<script src="https://unpkg.com/[email protected]/lib/vue-meta.js"></script>
- Import Vue Meta with Vue Router in your main application file, if you are writing an ES6 JavaScript app:
//main.js
import Vue from 'vue'
import Router from 'vue-router'
import Meta from 'vue-meta'
Vue.use(Router)
Vue.use(Meta)
export default new Router({
//...
})
- Then, you can use it in any Vue component, as follows:
// app.vue
var { data } = await axios.get(...)
export default {
metaInfo () {
return {
title: 'Nuxt',
titleTemplate: '%s | My Awesome Webapp',
meta: [
{ vmid: 'description', name: 'description', content: 'My
Nuxt portfolio...