过滤

作者: 知识分享share | 来源:发表于2018-04-01 21:33 被阅读0次
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>vue</title>
        <script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js">
        </script>
        <style>
        </style>
    </head>
    <body>
    <h1>多个实例</h1>
        <div id="app-one">
    
            <input  v-model="text" type="text">
            <!-- <button v-on:click="handleClick()">add</button> -->
            <ul>
                       <li v-for="(data,index) in processDatalis" :key="data">
                        {{data}}</li>
                       
            </ul>       
        </div>
    </body>
    </html>
    <script>
      var vm = new Vue({
            el: "#app-one",
            data:{
                text:"",
                datalist:["sdfs","wewef","vdfvwe","123","53454"]
            },
            methods:{
                handleClick(){
                    this.datalist.push(this.text);
                }
            },
            computed:{
                processDatalis(){
                    return this.datalist.filter((item,index)=>item.indexOf(this.text)>-1);
                }
            }
        });
    </script>
    
    

    相关文章

      网友评论

          本文标题:过滤

          本文链接:https://www.haomeiwen.com/subject/sbnacftx.html