![](/img/trans.png)
[英]So I am trying to get a set of items from an array using a for loop and displaying them into a context menu sub menu, but somehow I am not able to
[英]I am currently trying to return some data from an array displaying menu items into my search bar
我目前正在嘗試創建一個搜索欄,以使用戶輕松使用,以便他們可以輸入任何成分(例如“ A”)的首字母,並返回與該項目關聯的每個成分項目。 例如“鱷梨”
到目前為止,我只創建了一系列的成分。 我是編碼的新手,所以不確定如何啟動此過濾器列表。
這是我的成分數組的簡要說明
const ingredients: any = `{
"ingredients" : [
{
"ingredient" : "Avocado",
"category" : "Prepped"
"servings" : 35
},
{
"ingredient" : "Chopped Bacon",
"category" : "No Prep",
"servings" : 40,
}
]
]
我的預期結果是用戶在搜索欄中輸入“ a”,菜單上的配料會彈出,例如...“鱷梨”,“芝麻菜”,“蘋果”等。請記住,我的菜單是可折疊。 那么這將如何工作?
使用array.filter編寫過濾器,並提供客戶輸入。 文檔在這里
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.