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:
|
<<: Search engine free collection of website entrances
>>: A brief discussion on the underlying principle of mysql join
Scary, isn't it! Translation in the picture: ...
Before reading this article, I hope you have a pr...
Recently, https has been enabled on the mobile ph...
The ".zip" format is used to compress f...
1. Introduction to Data Integrity 1. Introduction...
I updated MySQL 8.0 today. The first problem: Nav...
1. Import mysql command The mysql command import ...
The search binary tree implementation in JavaScri...
I used js to create a package for converting Chin...
1. mysql export file: SELECT `pe2e_user_to_compan...
Table of contents Preface What does yarn create d...
1. There are many Python version management tools...
Table of contents Introduction to the Decorator P...
Recently, when I was using C# to make a Web progra...
In react-router, the jump in the component can be...