Given an input box and a search button, when the input box gets the focus, the user is prompted for the latest search content, how to implement it, and how to implement it. Which tests are required to ensure the robustness. Given an input box and a search button, when the input box gets the focus, the user is prompted for the latest search content, how to implement it, and how to implement it. Which tests are required to ensure the robustness.
Reply content:
Given an input box and a search button, when the input box gets the focus, the user is prompted for the latest search content, how to implement it, and how to implement it. Which tests are required to ensure the robustness.
Let's talk about ideas.
Create a hidden ul list. The list contains the options to be selected.
Store input content in localstorage as an array.
Set the maximum length of the list array to be selected.
Extract and render the array content to the list.
We recommend that you use localstorage to store such persistent data.
Cookies are mainly used to authenticate identities.
User search records are generally stored in databases. When a user opens your site, the most recent records are loaded to the cache such as redis by default, and js events are triggered when the input box gets the focus, ajax is used to obtain the corresponding data from the background, and the background directly obtains the data from the cache and returns it to the front-end. The main function of cache is that a user only needs to trigger one database operation during a search process. The cache is updated after the user searches. After the user exits the site, the cache is updated to the database.
Use cookies in simple terms
Guaranteed compatibility or cookie
In addition to storing the client-side data in cookies, you can also consider memory databases such as redis or memcached proposed upstairs.
Use cookies to record users' recent search terms. When a user inputs a cookie and matches it with the value, a prompt is displayed to the user.
1. Store popular or recent search content in json files or databases.
2. Place the search content locally.
3. Text Similarity algorithms are used to input the search content and output the most similar search content to the input content.
LocationStorage saves the user's search history and traverses it.