我正在建立一个简单的食谱网站由Strapi。现在我想让一个Recipe
有这么多Ingredient
。因此,有两个集合,它们在许多方面存在关系(因为我不需要指向或链接回Recipe
)
但是,在Content中,在创建一个Ingredient
之前,我必须创建一些Recipe
项。在同一个页面中创建或编辑Ingredient
时是否可以创建Recipe
?
发布于 2022-02-05 17:44:27
是的,在components
中使用strapi
是可能的。因此,基本上,您需要创建一个Recipe
集合和Ingredient
组件,并将该组件链接到作为可重复组件的Recipe
集合。这样,当您创建一个Recipe
条目时,您将能够动态地添加/编辑成分条目。
看看这个链接,了解如何创建组件。
创建组件后,按照以下步骤将其链接到Recipe
集合:
Recipe
集合并添加现有的component
。Repeating component
。Recipe
集合的更改,然后尝试创建一个条目。您将获得以下用户界面,它允许您动态地编辑/添加成分。populate
键将在URL中出现,如下所示:
http://localhost:1337/api/receipes?populate=ingredients
https://stackoverflow.com/questions/70990039
复制相似问题