当前位置: 移动技术网 > IT编程>脚本编程>vue.js > vuejs通过filterBy、orderBy实现搜索筛选、降序排序数据

vuejs通过filterBy、orderBy实现搜索筛选、降序排序数据

2018年05月07日  | 移动技术网IT编程  | 我要评论

怀旧配音联盟小夏,侯志慧,抗战胜利手抄报

直接贴代码了:

先上输入前的样子:

<style>
#example{margin:100px auto;width:600px;}
.show{margin:10px;}
#searchtext{display: block;margin:0 auto 10px;height:24px;line-height: 24px;width:200px;}
.content ul li{text-align: center;}
.content ul li span{display: inline-block;width:150px;font-size:15px;color:#000;}
</style>
</head>
<body>
<div id="example">
 <input type="text" id="searchtext" placeholder="搜索id或者姓名" v-model="searchdata"/>
 <div class="content">
  <ul>
   <li v-for="item in items | filterby searchdata in 'id' 'name' | orderby 'name' '-1'">
    <span>{{item.id}}</span>
    <span>{{item.name}}</span>
    <span>{{item.time}}</span>
   </li>
  </ul>
 </div>
</div>
<script>
 var example1 = new vue({
  el: '#example',
  data: {
   searchdata:'',
  items: [
   {id:'1008',name:'涛涛',time:'20170207'},
   {id:'1098',name:'合同',time:'20170213'},
   {id:'1107',name:'晓丽',time:'20170304'},
   {id:'1004',name:'小兰',time:'20170112'},
   {id:'1102',name:'财务',time:'20170203'},
   {id:'1108',name:'哈哈',time:'20170208'},
   {id:'1345',name:'测试',time:'20170201'},
  ] 
  },
  ready:function(){
   
  },
  watch:{
   items:{
    handler:function(val,oldval){
     
    },
    deep:true
   }
  },
  
  methods:{
   
  }
 })
</script>

当在输入框中输入'合同',得到结果如图:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网