How to use front-end search in vue2?
This article mainly introduces the vue2 front-end search implementation example. Now I will share it with you and give you a reference.
When the project data is small, small things like searching have to be left to our front-end. Important statement, suitable for small projects! ! ! ! !
In fact, the principle is very simple. The small demo is to search for city names or search according to rankings.
<p> <input type="text" v-model="name" placeholder="点击搜索按钮筛选" /> <input type="button" @click="search" /> </p>
<table> <tbody> <tr v-for="item in listt0"> <td> <a v-text="item.sort"></a> </td> <td> <a v-text="item.City"></a> </td> <td> <a :style="{'color':item.sort<=10?'#f2972e':''}" v-cloak>{{item.Data | two}}</a> </td> <td><span v-text="item.Good"></span></td> </tr> </tbody> </table>
After the page layout is successful, it is time to configure the js. The first is data initialization.
data:{ list0:[],//原始 listt0:[],//处理过的 name:'',//搜索框内容 },
Next, get the background data. The background data must be passed to the front end all at once. You know the reason.
created:function(){ //这获取数据且list0以及listt0都为获取到的数据 },
The implementation of search, if it is a number, search according to sort, if it is not a number, search according to city. A simple search and you're done.
methods:{ search:function(){//搜索 var _this=this; var tab=this['list0']; if(this.name){ _this['listt0']=[]; if(!isNaN(parseInt(_this.name))) { for(i in tab) { if(tab[i].sort == parseInt(_this.name)) { _this['listt0'].push(tab[i]); }; }; } else { for(i in tab) { if(tab[i].City.indexOf(_this.name) >= 0) { _this['listt0'].push(tab[i]); }; }; }; }else{ alert('请输入筛选条件!') }; } },
Little knowledge points:
1. :style="{'color':item.sort<=10?'#f2972e ':''}" :style sets the text color of the top 10.
2. !isNaN(parseInt(_this.name)) Determines whether the input is a number or text. If there are numbers, it will search according to the numbers.
3. Filter two
filters: {//保留两位小数点 two : function(value){ if (!value) { return ''}; return value.toFixed(2); } }
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
How to learn the process and child_process modules in node (detailed tutorial)
By using Vue2.0 Implement http request and loading display in
Method of cross-domain request through jQuery JSONP (detailed tutorial)
The above is the detailed content of How to use front-end search in vue2?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How does Xianyu search for users? In the software Xianyu, we can directly find the users we want to communicate with in the software. But I don’t know how to search for users. Just view it among the users after searching. Next is the introduction that the editor brings to users about how to search for users. If you are interested, come and take a look! How to search for users in Xianyu? Answer: View details among the searched users. Introduction: 1. Enter the software and click on the search box. 2. Enter the user name and click Search. 3. Select [User] under the search box to find the corresponding user.

How to use Baidu Advanced Search Baidu search engine is currently one of the most commonly used search engines in China. It provides a wealth of search functions, one of which is advanced search. Advanced search can help users search for the information they need more accurately and improve search efficiency. So, how to use Baidu advanced search? The first step is to open the Baidu search engine homepage. First, we need to open Baidu’s official website, which is www.baidu.com. This is the entrance to Baidu search. In the second step, click the Advanced Search button. On the right side of the Baidu search box, there is

In the era dominated by intelligence, office software has also become popular, and Wps forms are adopted by the majority of office workers due to their flexibility. At work, we are required not only to learn simple form making and text entry, but also to master more operational skills in order to complete the tasks in actual work. Reports with data and using forms are more convenient, clear and accurate. The lesson we bring to you today is: The WPS table cannot find the data you are searching for. Why please check the search option location? 1. First select the Excel table and double-click to open it. Then in this interface, select all cells. 2. Then in this interface, click the "Edit" option in "File" in the top toolbar. 3. Secondly, in this interface, click "

The mobile Taobao app software provides a lot of good products. You can buy them anytime and anywhere, and everything is genuine. The price tag of each product is clear. There are no complicated operations at all, making you enjoy more convenient shopping. . You can search and purchase freely as you like. The product sections of different categories are all open. Add your personal delivery address and contact number to facilitate the courier company to contact you, and check the latest logistics trends in real time. Then some new users are using it for the first time. If you don’t know how to search for products, of course you only need to enter keywords in the search bar to find all the product results. You can’t stop shopping freely. Now the editor will provide detailed online methods for mobile Taobao users to search for store names. 1. First open the Taobao app on your mobile phone,

PHP and Vue: a perfect pairing of front-end development tools. In today's era of rapid development of the Internet, front-end development has become increasingly important. As users have higher and higher requirements for the experience of websites and applications, front-end developers need to use more efficient and flexible tools to create responsive and interactive interfaces. As two important technologies in the field of front-end development, PHP and Vue.js can be regarded as perfect tools when paired together. This article will explore the combination of PHP and Vue, as well as detailed code examples to help readers better understand and apply these two

As a C# developer, our development work usually includes front-end and back-end development. As technology develops and the complexity of projects increases, the collaborative development of front-end and back-end has become more and more important and complex. This article will share some front-end and back-end collaborative development techniques to help C# developers complete development work more efficiently. After determining the interface specifications, collaborative development of the front-end and back-end is inseparable from the interaction of API interfaces. To ensure the smooth progress of front-end and back-end collaborative development, the most important thing is to define good interface specifications. Interface specification involves the name of the interface

Django is a web application framework written in Python that emphasizes rapid development and clean methods. Although Django is a web framework, to answer the question whether Django is a front-end or a back-end, you need to have a deep understanding of the concepts of front-end and back-end. The front end refers to the interface that users directly interact with, and the back end refers to server-side programs. They interact with data through the HTTP protocol. When the front-end and back-end are separated, the front-end and back-end programs can be developed independently to implement business logic and interactive effects respectively, and data exchange.

In front-end development interviews, common questions cover a wide range of topics, including HTML/CSS basics, JavaScript basics, frameworks and libraries, project experience, algorithms and data structures, performance optimization, cross-domain requests, front-end engineering, design patterns, and new technologies and trends. . Interviewer questions are designed to assess the candidate's technical skills, project experience, and understanding of industry trends. Therefore, candidates should be fully prepared in these areas to demonstrate their abilities and expertise.
