简体   繁体   English

我目前正在尝试从显示菜单项的数组中返回一些数据到我的搜索栏中

[英]I am currently trying to return some data from an array displaying menu items into my search bar

I am currently trying to create a search bar to make it easy on my users so that they can type in the first letter of any ingredient such as "A" and it returns every ingredient item that is associated with that item. 我目前正在尝试创建一个搜索栏,以使用户轻松使用,以便他们可以输入任何成分(例如“ A”)的首字母,并返回与该项目关联的每个成分项目。 Such as "Avocado" 例如“鳄梨”

So far I have only created the array of ingredients . 到目前为止,我只创建了一系列的成分。 I am kind of new to coding so I am not sure how to get this filter list started. 我是编码的新手,所以不确定如何启动此过滤器列表。

Here's a brief explanation of my ingredient array 这是我的成分数组的简要说明

const ingredients: any = `{
  "ingredients" : [
  {
     "ingredient" : "Avocado",
      "category" : "Prepped"
      "servings" : 35
 },
 {
     "ingredient" : "Chopped Bacon",
     "category" : "No Prep",   
      "servings" : 40,
 }
    ]

] ]

My expected results are for the user to type in "a" into the search bar and ingredients from the menu will pop up such as... "Avocados", "Arugula", "Apples" etc. Please keep in mind my menu is collapsible. 我的预期结果是用户在搜索栏中输入“ a”,菜单上的配料会弹出,例如...“鳄梨”,“芝麻菜”,“苹果”等。请记住,我的菜单是可折叠。 So how will this work? 那么这将如何工作?

Write filter using array.filter and provide customer input to it. 使用array.filter编写过滤器,并提供客户输入。 Documentation is here 文档在这里

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 因此,我试图使用for循环从数组中获取一组项目并将其显示到上下文菜单子菜单中,但是以某种方式,我无法 - 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 我正在尝试创建一个下拉菜单,用于存储餐馆菜单中的项目,使用vanilla JavaScript传递一组对象 - I am trying to create a drop down menu which stores items from a restaurant menu, using vanilla JavaScript by passing it an array of objects 我试图只返回包含匹配键的数组中的项目,其中键来自单独的数组 - I am trying to only return items in an array that contain a matching key with a true value where the key comes from a separate array 单击时,我正在尝试将活动 class 添加到我网站上的导航栏项目 - I am trying to add an active class to my nav bar items on my website when clicked 我正在尝试将对象中的一些值推送到 3 维数组中 - I am trying to push some values from an object into a 3 dimensional array Vuejs / javascript / 我正在尝试连接一个搜索栏来搜索我的表格并根据我的输入显示结果 - Vuejs / javascript / I am trying to connect a search bar that searches my table and displays the results according to my input 我正在尝试从函数中提取我的doc.data数组并在范围外使用它 - I am trying to pull my doc.data Array from within a function and use it outside the scope 我正在从 API 请求数据。 目前,我以对象数组的形式获取数据,但无法在浏览器上呈现输出 - I am requesting data from an API. Currently, I am getting data as an array of objects but I'm not able to render output on the browser 我正在尝试显示从我的 API 获得的数据,但没有显示我正在使用 JS 使用它 - I am trying to show my data obtained from my API but it is not shown I am consuming it with JS 我正在从数据库中获取表数据并显示在表上,但数据表搜索无法处理数据 - I am getting table data from database and displaying on table but datatables search is not working on data
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM