0๐
โ
i did this simple task and worked like charm:
data(){
return{
api_value:0
}
},
beforeCreate(){
axios.get('my-api-link)
.then(response=>{
this.api_value = response.data.api_value
})
},
computed:{
inject_theme(){
if(this.api_value ==1)
return '/theme/dark.css'
else if (this.api_value ==2)
return '/theme/dark.1.css'
else if (this.api_value ==3)
return '/theme/dark.2.css'
}
},
head () {
return {
title: this.title,
meta: [
{ hid: 'description', name: this.inject_theme, content: 'My custom description' }
],
link:[
{rel:'stylesheet',href:this.inject_theme}
]
}
}
Source:stackexchange.com