当前位置:   article > 正文

Uni-app/Vue/Js本地模糊查询,匹配所有字段includes和some方法结合使用e_uniapp 模糊查询

uniapp 模糊查询

天梦星服务平台 (tmxkj.top)icon-default.png?t=N7T8https://tmxkj.top/#/

1.第一步 需要一个数组数据

      

  1. {
  2. "week": "全部",
  3. "hOutName": null,
  4. "weekendPrice": null,
  5. "channel": "门市价",
  6. "hOutId": 98,
  7. "cTime": "2024-03-18 15:42:07",
  8. "weekdayPrice": 120.00,
  9. "arithmeticType": null,
  10. "sId": 1,
  11. "pOutId": null,
  12. "pOutName": null,
  13. "changePriceType": "指定金额",
  14. "holidayPrice": null,
  15. "startTime": "2024-03-20",
  16. "endTime": "2024-03-20",
  17. "id": 34,
  18. "cUserCode": "19969123206",
  19. "changePriceRule": null
  20. },
  21. {
  22. "week": "全部",
  23. "hOutName": null,
  24. "weekendPrice": null,
  25. "channel": "门市价",
  26. "hOutId": 98,
  27. "cTime": "2024-03-18 15:40:41",
  28. "weekdayPrice": 12.00,
  29. "arithmeticType": null,
  30. "sId": 1,
  31. "pOutId": null,
  32. "pOutName": null,
  33. "changePriceType": "指定金额",
  34. "holidayPrice": null,
  35. "startTime": "2024-03-20",
  36. "endTime": "2024-03-21",
  37. "id": 33,
  38. "cUserCode": "19969123206",
  39. "changePriceRule": null
  40. },

2.第二步 需要一个程序员把以下方法复制进去

  1. const data = [{
  2. "week": "全部",
  3. "hOutName": null,
  4. "weekendPrice": null,
  5. "channel": "门市价",
  6. "hOutId": 98,
  7. "cTime": "2024-03-18 15:42:07",
  8. "weekdayPrice": 120.00,
  9. "arithmeticType": null,
  10. "sId": 1,
  11. "pOutId": null,
  12. "pOutName": null,
  13. "changePriceType": "指定金额",
  14. "holidayPrice": null,
  15. "startTime": "2024-03-20",
  16. "endTime": "2024-03-20",
  17. "id": 34,
  18. "cUserCode": "19969123206",
  19. "changePriceRule": null
  20. }];
  21. const valueToMatch = "门市价"; // 需要匹配的值
  22. const result = data.filter(item => {
  23. return Object.values(item).some(val => val?.toString().includes(valueToMatch));
  24. });
  25. console.log(result);

3.第三步 你可以关闭页面了

            好孩子 加油!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/566487
推荐阅读
相关标签
  

闽ICP备14008679号