vuejs通過filterBy、orderBy實現(xiàn)搜索篩選、降序排序數(shù)據(jù)
更新時間:2020年10月26日 13:24:44 作者:孟然
這篇文章主要為大家詳細介紹了vuejs通過filterBy、orderBy實現(xiàn)搜索篩選、降序排序數(shù)據(jù)實例,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了vuejs實現(xiàn)搜索篩選、降序排序數(shù)據(jù)的具體代碼,供大家參考,具體內容如下
先上輸入前的樣子:
<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>
當在輸入框中輸入'合同',得到結果如圖:
關于vue.js組件的教程,請大家點擊專題vue.js組件學習教程進行學習。
更多vue學習教程請閱讀專題《vue實戰(zhàn)教程》
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
Vue+Element?UI實現(xiàn)復制當前行數(shù)據(jù)的功能
這篇文章主要介紹了如何使用Vue?+?Element?UI?實現(xiàn)在列表的操作欄新增一個復制按鈕,復制當前行的數(shù)據(jù)可以打開新增彈窗后亦可以跳轉到新增頁面,感興趣的小伙伴可以參考下2023-11-11