JS searches for keywords and displays them.

as shown in the figure, when you enter a text with the keyword "20", the text string with 20 will be displayed, and the great god will provide the next idea

.
Mar.03,2021

example:
let data = [

{title:'20',singer:''},
{title:'30',singer:''},
{title:'40',singer:''},
{title:'50',singer:''},
{title:'60',singer:''},
{title:'20',singer:'2'}

];

let result = data.filter ((obj) = > {

return obj.title.indexOf('20') != -1;

})


search based on whether the title contains keywords? If:

  1. Loop list, whether the title contains' 20century li index of;
  2. filter out new lists based on index

provides an idea for reference only. First of all, you can add an attribute named _ str for each option in the song list array, in which the music title, singer and album are aggregated into a string, and then the value to be searched in the input box is search,. Compare the search with the _ str query in each item in the song list, if any, put it in the new array _ arr, and then check the length of _ arr. If the length is 0, it indicates that you didn't find any information you thought about. Instead, it displays the _ arr data
-hand-only hope it can help you

.
Menu