【发布时间】:2020-02-12 11:55:59
【问题描述】:
我正在尝试使用导入的组件映射 graphql 查询。数据已正确连接,但未通过。我收到错误Missing product attribute on result
我缩小了问题在于数据传递的范围。
这是我所拥有的:
<template>
<div class="CoffeeSection">
<h2>Coffees</h2>
<div class="Cards">
<CoffeeCard
v-for="product of products"
:key="product.id"
:title="product.title"
:slug="product.slug"
:image="product.image.handle"
></CoffeeCard>
</div>
</div>
</template>
我是否在此处适当地映射查询?
<script>
import CoffeeCard from "./CoffeeCard";
import gql from "graphql-tag";
const products = gql`
query {
products {
title
image {
url
handle
}
description
price
slug
category {
name
description
products {
title
image {
url
handle
}
}
}
}
}
`;
export default {
name: "Coffees",
data: () => ({
loading: 0,
products: []
}),
apollo: {
$loadingKey: "loading",
product: {
query: products
}
},
components: {
CoffeeCard
}
};
</script>
我收到错误 Missing product attribute on result。
【问题讨论】: