Example of a simple auto-complete input box in vue

亚连
Release: 2018-05-30 17:43:19
Original
2944 people have browsed it

This article mainly introduces an example of Vue's simple auto-complete input box. Now I share it with you and give it as a reference.

Implement an input box. After inputting information, the data returned by the background is displayed for the user to choose. The elm component was used before, but that one was a bit big. . . In simple cases, implementing one yourself can also meet the requirements. . . Maybe. . .

The theme includes an input for input, a p for displaying data, and p is the data item item

When you press Enter in the input When, the data will be obtained from the background based on the information. If the user clicks elsewhere and the input loses focus, the p in the prompt should also be put away

bug:

In the blur event, if Directly setting isShow to false will cause problems. The focus will be lost first and the display panel will disappear, so your clicks will not be monitored. . . Set a timer to close the panel 10ms after clicking, and the problem is solved. . .

Display p to expand the content, change the layout of other components, set the properties of p, and set the height to 0. If the z-index is large, the position of other components will not be changed

height: 0; z-index: 999;
Copy after login
Copy after login

SIMPLE IMPLEMENTATION CODE

 
Copy after login

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

A simple example of the local preview effect of uploaded images implemented by jQuery

Detailed explanation of what new() does in Javascript What

Sample code for file upload and download in Koa2

The above is the detailed content of Example of a simple auto-complete input box in vue. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!