{"pid":-1,"layers":[{"component":{"id":"21de350a-9acc-4fc1-9290-b53b0f3e6939","name":"方块翻牌器","alias":"Cubeflop","version":"v1.0.0","thumbnail":"images/widgets/tools/tool/cubeflop.png","width":450,"height":60,"pnode":{"type":"tool","pnode":{"type":"tools"}},"option":{"suffix":"/ppm","duration":300,"prefix":"NO₂","decimals":1,"textStyle":{"fontSize":30,"color":"rgba(61, 156, 255, 1)","textShadow":{"show":false,"x":0,"y":0,"value":14,"color":"rgba(15, 146, 255, 1)"},"colorSecondary":"rgba(221, 221, 221,1)","fontWeight":"bold"},"backgroundColor":"rgba(8, 21, 39, 1)"},"source":[{"name":"default","source":{"type":"mysql","filter":{"isFilter":false,"filterId":-1},"isAutoUpdate":true,"autoUpdateTime":6,"mapping":[{"name":"value","required":true,"description":"值","type":"number","mapping":"value"}],"static":[{"value":1234.56}],"api":{"sourcesId":-1,"requestType":"GET","requestHeader":{"token":null},"getParam":"","postParam":{},"requestUrl":"","cookie":false,"postMethods":"raw"},"mysql":{"sourcesId":"ea93b0c0-ff44-11ed-a2ea-8fe1718b947a","database":"jxjk","sql":"SELECT*from device_data_update WHERE id =12","sources":{"id":"ea93b0c0-ff44-11ed-a2ea-8fe1718b947a","name":"测试","description":"","host":"192.168.2.66","port":3306,"user":"root","password":"123"}},"elasticsearch":{"sourcesId":-1,"query":{"index":"_all"}},"mongodb":{"sourcesId":-1,"query":{},"collection":-1},"csv":{}}}]},"id":"3f8433b2-1902-4141-8b17-fc36a9a1001c","name":"图层-17-副本(6)","type":"layer","left":29.091,"top":775,"width":450,"height":50,"widthHeightLink":false,"zIndex":8,"locked":false,"visible":true,"opacity":1,"rotate":0,"rotateX":0,"rotateY":0,"mixBlendMode":null,"background":{"color":"rgba(255, 255, 255, 0)"},"border":{"width":0,"color":"#2ed64a","style":"solid"},"radius":{"value":0},"shadow":{"show":false,"color":"rgba(132, 132, 132, 1)","value":5,"ambiguity":10,"x":3,"y":2},"padding":{"value":0},"animation":"","animations":[],"baseLeft":1220,"baseTop":515,"randomRgbaColor":"rgba(255,255,255,0.2)","rightX":506.364,"rightY":781.81}]} 在JavaScript中只留下value一个字段、
时间: 2023-07-08 13:56:17 浏览: 107
可以使用以下代码将value字段提取出来:
```javascript
const data = {"pid":-1,"layers":[{"component":{"id":"21de350a-9acc-4fc1-9290-b53b0f3e6939","name":"方块翻牌器","alias":"Cubeflop","version":"v1.0.0","thumbnail":"images/widgets/tools/tool/cubeflop.png","width":450,"height":60,"pnode":{"type":"tool","pnode":{"type":"tools"}},"option":{"suffix":"/ppm","duration":300,"prefix":"NO₂","decimals":1,"textStyle":{"fontSize":30,"color":"rgba(61, 156, 255, 1)","textShadow":{"show":false,"x":0,"y":0,"value":14,"color":"rgba(15, 146, 255, 1)"},"colorSecondary":"rgba(221, 221, 221,1)","fontWeight":"bold"},"backgroundColor":"rgba(8, 21, 39, 1)"},"source":[{"name":"default","source":{"type":"mysql","filter":{"isFilter":false,"filterId":-1},"isAutoUpdate":true,"autoUpdateTime":6,"mapping":[{"name":"value","required":true,"description":"值","type":"number","mapping":"value"}],"static":[{"value":1234.56}],"api":{"sourcesId":-1,"requestType":"GET","requestHeader":{"token":null},"getParam":"","postParam":{},"requestUrl":"","cookie":false,"postMethods":"raw"},"mysql":{"sourcesId":"ea93b0c0-ff44-11ed-a2ea-8fe1718b947a","database":"jxjk","sql":"SELECT*from device_data_update WHERE id =12","sources":{"id":"ea93b0c0-ff44-11ed-a2ea-8fe1718b947a","name":"测试","description":"","host":"192.168.2.66","port":3306,"user":"root","password":"123"}},"elasticsearch":{"sourcesId":-1,"query":{"index":"_all"}},"mongodb":{"sourcesId":-1,"query":{},"collection":-1},"csv":{}}}]},"id":"3f8433b2-1902-4141-8b17-fc36a9a1001c","name":"图层-17-副本(6)","type":"layer","left":29.091,"top":775,"width":450,"height":50,"widthHeightLink":false,"zIndex":8,"locked":false,"visible":true,"opacity":1,"rotate":0,"rotateX":0,"rotateY":0,"mixBlendMode":null,"background":{"color":"rgba(255, 255, 255, 0)"},"border":{"width":0,"color":"#2ed64a","style":"solid"},"radius":{"value":0},"shadow":{"show":false,"color":"rgba(132, 132, 132, 1)","value":5,"ambiguity":10,"x":3,"y":2},"padding":{"value":0},"animation":"","animations":[],"baseLeft":1220,"baseTop":515,"randomRgbaColor":"rgba(255,255,255,0.2)","rightX":506.364,"rightY":781.81}]};
const value = data.layers[0].component.source[0].source.static[0].value;
console.log(value); // 输出 1234.56
```
阅读全文