nuxt.js - Nuxt 无法在页面组件中实现 head 功能
问题描述
<template>
<nuxt />
</template>
<script>
import axios from "axios"
export default {
name: "index",
layout: "EwArticle",
head() {
return {
title: this.title
}
},
async asyncData({ params }){
return axios( `https://restAPI`, {
method: "GET",
params: {
include: params.id
}
}).then(response => {
return {
title: response.data[0].title.rendered,
description: response.data[0].excerpt.rendered.replace(/(<([^>]+)>)/gi, ""),
image: response.data[0].acf["img#1"].sizes["medium_large"]
}
});
}
}
</script>
我上面的代码示例来自嵌套页面组件。asyncData 正在按预期运行,但从未达到 head 函数。我完全糊涂了,因为我不知道为什么在我的所有页面组件上我都无法达到我的 head 功能——即使没有控制台也是如此。有人可以看看吗?
nuxt 配置模式是通用的,我通过 generate 构建我的 nuxt 应用程序。
解决方案
推荐阅读
- performance - 某些静态资产的 HTTP 请求等待时间为 10 秒
- c# - 在 Linq 中取消提交到数据库
- docker - Nginx 没有在 docker 容器中运行
- html - 如何对齐 2 个 div 的左右对齐
- elasticsearch - ReactiveSearch - 尝试从映射中查询确切值
- javascript - javascript中数据库字段的撇号
- angular - FormData SyntaxError:JSON 中位置 0 处的意外标记 U
- python - PyTest Tornado:'SimpleAsyncHTTPClient' 不可迭代
- reactjs - How do I test a simple function in create react app?
- c# - ASP.NET Core DI inside a singleton class