如何解决如何在nuxt js中动态头部
我使用了 nuxt.js 的应用程序 如何从 api 设置动态元标记? 在 asyncData 中从 api 获取但未在 head 中设置标题! 在 head 中设置标题后不等待从 api 获取:{} !
async asyncData({ params,app }) {
try {
let post = await app.$axios.get("/api/post/post?slug=" + params.slug);
return {
slug: params.slug,post: post.data.result,categoryName: post.data.result.category.categoryName,};
} catch (e) {
console.log(e);
}
},mounted() {
this.readDataFromAPI(this.$route.params.slug);
},head() {
console.log('post title is : next line');
console.log(this.post.title);
return {
title: this.post.title,meta: [
{
hid: "title",name: "title",content: this.post.title,},{
hid: "apple-mobile-web-app-title",name: "apple-mobile-web-app-title",{
hid: "og:title",name: "og:title",{
hid: "description",name: "description",{
hid: "og:description",name: "og:description",],};
},
我尝试从已挂载和创建的 api 中获取数据,以及 asyncData 和 fetch 但未设置元标记!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。