zoukankan      html  css  js  c++  java
  • vue分类筛选方法,filer

    使用computed 方法来过滤筛选数据;也可以使用methods 方式来筛选过滤数据

    代码如下:


    <body>
      <div id="app">
        <ul>
          <li v-for="item in list">{{item.n}}</li>
        </ul>
        <ul>
          <li v-for="item in listCmputed">{{item.n}}</li>
        </ul>
        <ul>
          <li v-for="item in listMe(list)">{{item.n}}</li>
        </ul>

      </div>
    </body>
    <script>
      var app=new Vue({
      el:'#app',
      data:{
        list:[{n:11},{n:22},{n:33},{n:44},{n:55},{n:66}],
      },
      computed:{
        listCmputed:function(){
          return this.list.filter(function(item){
            return item.n>=33
          })
        }  / /44,55,66
      }, 
      methods:{
        listMe:function(list){
          return list.filter(function(item){
            return item.n<=33
          })
        } / /11,22,33
      }
    })
    </script>

  • 相关阅读:
    GC(垃圾分代收集)
    排序算法总结
    Redis中的数据结构
    事务的隔离性(续篇)
    手写Spring mvc框架 (二)
    MySql日志与事务的隔离级别
    手写Spring mvc框架 (一)
    IO流
    随笔三(Ajax)
    关于博主noble_
  • 原文地址:https://www.cnblogs.com/AlbertP/p/10728411.html
Copyright © 2011-2022 走看看