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

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

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

      

{
                "week": "全部",
                "hOutName": null,
                "weekendPrice": null,
                "channel": "门市价",
                "hOutId": 98,
                "cTime": "2024-03-18 15:42:07",
                "weekdayPrice": 120.00,
                "arithmeticType": null,
                "sId": 1,
                "pOutId": null,
                "pOutName": null,
                "changePriceType": "指定金额",
                "holidayPrice": null,
                "startTime": "2024-03-20",
                "endTime": "2024-03-20",
                "id": 34,
                "cUserCode": "19969123206",
                "changePriceRule": null
            },
            {
                "week": "全部",
                "hOutName": null,
                "weekendPrice": null,
                "channel": "门市价",
                "hOutId": 98,
                "cTime": "2024-03-18 15:40:41",
                "weekdayPrice": 12.00,
                "arithmeticType": null,
                "sId": 1,
                "pOutId": null,
                "pOutName": null,
                "changePriceType": "指定金额",
                "holidayPrice": null,
                "startTime": "2024-03-20",
                "endTime": "2024-03-21",
                "id": 33,
                "cUserCode": "19969123206",
                "changePriceRule": null
            },

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

const data = [{
    "week": "全部",
    "hOutName": null,
    "weekendPrice": null,
    "channel": "门市价",
    "hOutId": 98,
    "cTime": "2024-03-18 15:42:07",
    "weekdayPrice": 120.00,
    "arithmeticType": null,
    "sId": 1,
    "pOutId": null,
    "pOutName": null,
    "changePriceType": "指定金额",
    "holidayPrice": null,
    "startTime": "2024-03-20",
    "endTime": "2024-03-20",
    "id": 34,
    "cUserCode": "19969123206",
    "changePriceRule": null
}];

const valueToMatch = "门市价"; // 需要匹配的值

const result = data.filter(item => {
    return Object.values(item).some(val => val?.toString().includes(valueToMatch));
});

console.log(result);

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

            好孩子 加油!

  • 9
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值