Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does WeChat Mini Programs realize the search input box with search records

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "WeChat Mini Programs how to achieve the search input box with search records", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "WeChat Mini Programs how to achieve the search input box with search records" bar!

There is a requirement in the recent project, that is, you need an input box with search records, but you don't need to use the background, so you think of using the local cache setStorageSync.

Summarize the points you need to pay attention to:

1. Reverse the search time.

Unshift: insert data in front of the array and change the array.

2. When spaces are added before and after the search content.

String.trim (); / / remove the spaces before and after

3. Maximum number of search records to be cached.

/ / if there are more than 8 search records, delete the oldest one

If (searchData.length > = 8) searchData.pop ()

/ / pop: deletes the last element of the array.

4. Enter the content that the search record already has.

/ / delete the search record first, and then add the element to the first place

/ / if there are duplicates in the search record, delete it.

For (let I = 0; I < searchData.length; iTunes +) {

If (searchData [I] = = this.data.inputValue.trim ()) {

SearchData.splice (iPol 1)

Break

}

}

/ / add search record

SearchData.unshift (inputValue.trim ())

Only the key code has been uploaded. If you have bug, please check it and modify it. It should not be a big problem.

At this point, I believe you have a deeper understanding of "WeChat Mini Programs how to achieve the search input box with search records". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report