Home > Software engineering >  how i make filter search in vue js with javascript
how i make filter search in vue js with javascript

Time:11-05

can i write a filter search code with just data and methods function?

i try do this :

var fil = new Vue ({
            el: '#app',
            data: {
                search: '',
                proL: ['css', 'c  ', 'cs#'],
            },
            methods: {
                filter: function(){

                        var search_key = this.search.val();
                        
                        this.proL.filter(function(){
                            this.proL.toggle(this.proL.text().indexOf(search_key) > -1);
                        });

                }
            }
        });

and this is the html code

<div id="app">
        <div >
          <input @keyup="filter()" type="text" v-model="search" placeholder="Search title.."/>
        </div>

        <div id="pro">
            <h4 v-for="item in proL">{{item}}</h4>
        </div>
    </div>

  • Related