1 | import { Search } from 'vant' ; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <template> <search v-model= "keyword" placeholder= "请输入关键字" @search= "handleSearch" > </search></template> <script src= "https://zz.bdstatic.com/linksubmit/push.js" ></script><script src= "https://hm.baidu.com/hm.js?09557d432c13273dfc40996016de61c4" ></script><script> export default { data() { return { keyword: '' }; }, methods: { handleSearch(value) { // 在这里进行数据筛选操作 console.log( '筛选关键字:' , value); } } }; </script> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | data() { return { list: [ { name: 'Apple' , type: '水果' }, { name: 'Carrot' , type: '蔬菜' }, { name: 'Banana' , type: '水果' }, { name: 'Cucumber' , type: '蔬菜' }, ] }; }, methods: { handleSearch(value) { // 在这里进行数据筛选操作 const result = this .list.filter(item => item.name.includes(value)); console.log( '筛选结果:' , result); } } |
本文为翻滚的胖子原创文章,转载无需和我联系,但请注明来自猿教程iskeys.com