Vue implements small search function

Vue implements small search function

This article example shares the specific code of Vue to implement the search function for your reference. The specific content is as follows

<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8">
  <title></title>
 </head>
 <body>
  <div id="app">
   <input type="text" v-model="keyword" placeholder="Enter keyword" />
   <div class="list">
    <div class="item" v-for="item in fFruit" :key="item">
     {{item}}
    </div>
   </div>
  </div>
 </body>
 <script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
 <script type="text/javascript">
  new Vue({
   el:"#app",
   data(){
    return {
     keyword:"",
     fruit:
      "Apple", "Sand apple", "Begonia", "Aronia", "Loquat", "Hawthorn", "Hawthorn", "Pear",
      "Snow pear", "Quincea", "Rose hip", "Rannon", "Apricot", "Cherry", "Peach", "Peach",
      "Nectarine", "Peach", "Plum", "Plum", "Prune", "White Jade Cherry", "Blackberry",
      "Raspberry", "Cloudberry", "Loganberry", "Brunette", "Strawberry", "Pineappleberry", "Orange",
      "Sugar orange", "orange", "lemon", "lime", "pomelo", "kumquat", "grapefruit", "citron",
      "Buddha's hand", "Finger orange", "Yellow fruit", "Cantaloupe", "Cantaloupe", "Honey melon", "Prickly horn melon"
     ]
    }
   },
   computed:{
    "fFruit"(){
     // If the keyword is empty, return all fruits if(this.keyword==""){
     return this.fruit;
    }else{
     // When a certain item in Frui contains keyword text, keep the current data // filter returns true to keep, false to filter out return this.fruit.filter(item=>{
      return item.includes(this.keyword)
     })
    }
    }
    
   }
  })
 </script>
</html>

result:

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Implementing a simple search box based on Vue.js
  • How to use vue + element to implement table paging and front-end search
  • Vue.js implements table functions of multi-condition filtering, searching, sorting and paging
  • Vue implements search function
  • Vue Element grouping + multi-selection + searchable Select selector implementation example
  • Vue el-autocomplete remote search drop-down box and implement automatic filling function (recommended)
  • Vue component practice searchable drop-down box function
  • Implementing a custom component for searchable drop-down box based on Vue
  • Vuejs uses filterBy and orderBy to implement search filtering and descending sorting of data
  • Detailed explanation of the use of Vue2.0 multi-condition search component

<<:  Search engine free collection of website entrances

>>:  A brief discussion on the underlying principle of mysql join

Recommend

Graphic tutorial on installing Ubuntu 18.04 on VMware 15 virtual machine

In the past few years, I have been moving back an...

How to deploy services in Windows Server 2016 (Graphic Tutorial)

introduction Sometimes, if there are a large numb...

Proxy realizes the principle of two-way binding of Vue3 data

Table of contents 1. Advantages of proxy vs. Obje...

Use SQL statement to determine whether the record already exists before insert

Table of contents Determine whether a record alre...

HTML tutorial, easy to learn HTML language (2)

*******************Introduction to HTML language (...

How to create an index on a join table in MySQL

This article introduces how to create an index on...

Detailed explanation of CocosCreator Huarongdao digital puzzle

Table of contents Preface text 1. Panel 2. Huaron...

WeChat applet calculator example

WeChat applet calculator example, for your refere...

JS generates unique ID methods: UUID and NanoID

Table of contents 1. Why NanoID is replacing UUID...

A simple method to regularly delete expired data records in MySQL

1. After connecting and logging in to MySQL, firs...

mysql join query (left join, right join, inner join)

1. Common connections for mysql INNER JOIN (inner...