【发布时间】:2021-05-08 09:19:07
【问题描述】:
由于某种原因,这个脚本只有一部分工作。但是new_students 查询不起作用。
import React from "react"
import styled from "styled-components"
import { Link, graphql } from "gatsby"
import Img from "gatsby-image"
import ClassImg from 'gatsby-background-image'
import Layout from "../components/layout"
import { Container, Row, Col } from 'reactstrap';
import 'bootstrap/dist/css/bootstrap.min.css'
import "./class.scss"
除此部分之外的其他所有内容<p>{classdesc.new_students.firstname}</p>
const ClassName = styled.div`
color: white;
`
const Section = styled.div`
margin-top: 20px
`
export default function Class({ data }) {
const classdesc = data.strapiClassList
return (
<Layout>
<Container className={`justify-content-md-center pt-5`}>
<Row className={`justify-content-md-center`}>
<Col className={`col-md-auto`}>
<ClassImg
Tag="section"
className={`class-img`}
fixed={classdesc.class_img.childImageSharp.fixed}
>
<ClassName className={`class-name text-center`}>{classdesc.classname}</ClassName>
</ClassImg>
<Section>
<p>{classdesc.days}</p>
<p>{classdesc.start} - {classdesc.end}</p>
<p>{classdesc.class_desc}</p>
<p>{classdesc.new_students.firstname}</p>
</Section>
</Col>
</Row>
</Container>
</Layout>
)
}
GraphQL
export const query = graphql`
query($slug: String!) {
strapiClassList(slug: { eq: $slug }) {
classname
zoomurl
days
start
end
class_desc
class_img {
childImageSharp {
fixed(width: 300) {
...GatsbyImageSharpFixed
}
}
}
new_students {
firstname
student_img {
childImageSharp {
fixed(width: 30) {
...GatsbyImageSharpFixed
}
}
}
}
}
}
`
【问题讨论】:
标签: postgresql graphql relationship gatsby strapi