reactjs - 添加从内容和 gatsby 生成的可点击标签
问题描述
非常关注这篇文章将标签添加到 Gatsby Contentful 博客到 T 但仍然找不到它不起作用的原因......
import React from "react"
import { graphql } from "gatsby"
export const query = graphql`
query($slug: String!, $tag: [String!]) {
contentfulBrunchPost(slug: { eq: $slug }, tag: { in: $tag }) {
title
slug
tag
}
}
`
const TagPost = props => {
return <h1>{props.data.contentfulBrunchPost.title}</h1>
}
export default TagPost
我收到错误“无法读取未定义的属性‘contentfulBrunchPost’”。graphiQL 在内容和 gatsby 方面非常新,所以指出正确的方向会很棒
解决方案
我建议去你的本地版本的 Graphiqlhttp://localhost:8000/___graphql
并复制你的确切查询。查询是否在那边返回数据?如果不是,那么您的查询可能不正确。如果它确实返回数据,那么您可以深入研究它以确定要在代码中使用的正确引用。
推荐阅读
- php - 为什么这一切都在
- 标签没有显示在我的网站上?
- c++ - std::optional 不可复制?
- javascript - 如何使用 javascript 将字符串编码到 windows 1256
- javascript - 有没有办法防止每个元素上的 slideToggle ?
- spring-boot - 运行springboot应用程序时出现错误,如应用程序无法启动
- java - SQL 数据库中的历史数据搜索
- amazon-web-services - 尝试访问 CloudWatch 上的 Lambda 日志时出错?
- xamarin.forms - 如何将 ImageSource.FromFile 转换为 Xamarin.Forms 中的流?
- amazon-web-services - 具有关联组的 AWS Cognito Admin GetUser
- visual-studio-2019 - 在 Visual Studio SQL Server 2017 数据库项目中禁用临时历史保留