6π
β
From the head documentation, type is Object or Function
So if you reformat your code a bit, you could write head
like this
head() {
const thread = threads.find(t => t.id === this.$route.params.id)
return {
title: thread ? thread.title : '',
meta: [
{
hid: 'description',
name: 'description',
content: thread ? thread.body : ''
}
]
}
},
π€ljubadr
0π
You should define thread
in data method
data () {
return {
thread: {
body: '',
}
}
}
Also, the head should be define as method, not a property.
head () {
return {
meta: [
{
hid: 'description',
name: 'description',
content: this.thread.body
}
]
}
}
π€Cong Nguyen
0π
aznable Apparently you must remove null from here
thread: null => thread: ""
and insert this inside async methods
async getId() {
this.thread = await threads.find(t => t.id === this.$route.params.id)
}
Best !
π€Birante
Source:stackexchange.com