Is it possible to get access to $metaInfo of current page in layout? It will be usefull to set page title (not title tag)
Any news? :)
Sorry for the late reply, you can try 1.0.0 now:
export default {
data() {
return { meta: {title: 'abc'} }
},
head() {
return {
title: this.meta.title
}
},
created() {
console.log(this.$metaInfo.title) // read meataInfo
this.meta.title = 'New Title' // set new title
}
}
@clarkdo thanks! Tried and in layouts/default.vue $metaInfo is not defined
Same too, can not access $metaInfo in layouts/default.vue. $metaInfo is not defined
@canhkieu
Can you provide a repo ? I have tried below which works for me
<template>
<div>
<nuxt/>
</div>
</template>
<script>
export default {
data() {
return { meta: {title: 'abc'} }
},
head() {
return {
title: this.meta.title
}
},
created() {
console.log(this.$metaInfo.title) // read meataInfo
this.meta.title = 'New Title' // set new title
}
}
</script>
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@clarkdo thanks! Tried and in layouts/default.vue
$metaInfois not defined