您好,登錄后才能下訂單哦!
本篇內容主要講解“vuejs怎么通過filterBy和orderBy實現搜索篩選、降序排序數據”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“vuejs怎么通過filterBy和orderBy實現搜索篩選、降序排序數據”吧!
先上輸入前的樣子:
<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>
當在輸入框中輸入'合同',得到結果如圖:
到此,相信大家對“vuejs怎么通過filterBy和orderBy實現搜索篩選、降序排序數據”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。