以下是前端使用JavaScript过滤state为0和state为1的数据,并计算它们的个数的示例代码:

// 原始数据
const data = [
    {
        "createBy": "",
        "createTime": null,
        "updateBy": "",
        "updateTime": null,
        "remark": "1AP(F)3",
        "id": 15554,
        "name": "1F-DDC-01",
        "ip": "192.168.40.53",
        "assetsTypeId": "[76,286]",
        "state": "0",
        "used": "0",
        "type": "新风机",
        "position": "1层东新风机房",
        "location": "HBSZW",
        "floor": "1",
        "longitude": "-0.000953",
        "latitude": "0.000147",
        "height": "0.058103",
        "deviceCode": "device53",
        "jsonData": null
    },
    // ... 其他数据
];

// 过滤state为0的数据
const state0Data = data.filter(item => item.state === "0");
console.log("state为0的数据个数:" + state0Data.length);

// 过滤state为1的数据
const state1Data = data.filter(item => item.state === "1");
console.log("state为1的数据个数:" + state1Data.length);

请将上述代码嵌入到您的前端项目中,然后运行它,将会在控制

createBy createTime null updateBy updateTime null remark 1APF3 id 15554 name 1F-DDC-01 ip 1921684053 assetsTypeId 76286 state 0

原文地址: https://www.cveoy.top/t/topic/iLN8 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录