Use vue-meta

York Chen
1 min readAug 31, 2020

install

$ npm i vue-meta

use in main.js

import Vue from 'vue'
import VueMeta from 'vue-meta'
Vue.use(VueMeta)

Vue template

<template>
<div class="Home"></div>
</template>
<script>
export default {
name: 'home',
metaInfo: {
title: 'Home',
},
}
</script>

Vue template load by axios

<template>
<div class="Home"></div>
</template>
<script>
export default {
name: 'home',
data() {
return {
title: this.getMetadata(),
}
},
methods: {
async getMetadata() {
const result = await axios.get(this.GLOBAL.API_URL + 'meta_api.php', { params: { url: this.$route.params.url } });
let metadata = result.data.data[0];
this.metadata = metadata;
}
},
metaInfo() {
return {
title: this.title,
}
}
}
</script>

--

--

York Chen

Cooking is an indispensable part of life. It is a taste that can’t be forgotten.