[ { "ZJH": "网点规划办公室", "c5": 958, "wcl": 42 }, { "ZJH": "运营服务部", "c5": 1973, "wcl": 59 }, { "ZJH": "网络金融部", "c5": 6430, "wcl": 68 } ] 请基于vue框架的js语句,处理以上数据,将wcl的值赋予data,最终处理为以下数据: data: [111, 256, 178, 152, 266, 132]
时间: 2023-07-21 12:02:23 浏览: 78
你可以使用以下的Vue框架的JavaScript代码来处理数据并生成`data`数组:
```javascript
data() {
return {
data: [],
};
},
created() {
const rawData = [
{
ZJH: "网点规划办公室",
c5: 958,
wcl: 42,
},
{
ZJH: "运营服务部",
c5: 1973,
wcl: 59,
},
{
ZJH: "网络金融部",
c5: 6430,
wcl: 68,
},
];
this.data = rawData.flatMap((item) => [item.wcl, item.c5]);
},
```
在上述代码中,我们首先定义了一个空数组`data`作为Vue组件的data属性。然后,在`created`生命周期钩子函数中,我们使用`flatMap`方法遍历原始数据数组`rawData`,对每个元素进行处理。
对于每个元素,我们将其`wcl`和`c5`的值分别添加到`data`数组中。最后,将处理后的数据赋值给`this.data`,即可得到最终的结果。
请注意,以上代码假设你已经正确配置了Vue框架,并将其与你的HTML模板进行了绑定。
相关问题
[ { "ZJH": "网点规划办公室", "c5": 958, "wcl": 42 }, { "ZJH": "运营服务部", "c5": 1973, "wcl": 59 }, { "ZJH": "网络金融部", "c5": 6430, "wcl": 68 } ] 请基于vue框架的js语句,处理以上数据,将wcl的值赋予data,最终处理为以下数据: data: [42, 59, 68]
你可以使用以下的Vue框架的JavaScript语句来处理这数据:
```javascript
<script>
new Vue el: '#app',
data: {
data []
},
mounted() const originalData = [
{
"ZH": "网点规办公室",
c5": 958,
"cl": 42
{
"ZH": "运营服务",
"c5":1973,
"cl": 59
},
{
"ZJH": "网络金融部",
"c5": 6430,
"wcl": 68
}
];
this.data = originalData.map(item => item.wcl);
}
});
</>
```
在上述代码中,`mounted` 钩子函数被用于在 Vue 实例挂载后执行数据处理操作。`originalData` 数组包含了原始的数据。通过 `map` 方法,我们提取出每个对象中的 `wcl` 值,并将它们赋值给了 `data` 数组。最终,`data` 数组的值为 `[42, 59, 68]`。
roslaunch moveit_setup_assistant setup_assistant.launch ... logging to /home/zjh/.ros/log/513e5cbe-09c0-11ee-a43a-e7f821379d26/roslaunch-zjh-6655.log Checking log directory for disk usage. This may take a while. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB. started roslaunch server http://zjh:40045/ SUMMARY ======== PARAMETERS * /rosdistro: noetic * /rosversion: 1.16.0 NODES / moveit_setup_assistant (moveit_setup_assistant/moveit_setup_assistant) auto-starting new master process[master]: started with pid [6681] ROS_MASTER_URI=http://localhost:11311 setting /run_id to 513e5cbe-09c0-11ee-a43a-e7f821379d26 process[rosout-1]: started with pid [6691] started core service [/rosout] process[moveit_setup_assistant-2]: started with pid [6694] /opt/ros/noetic/lib/moveit_setup_assistant/moveit_setup_assistant: error while loading shared libraries: libfcl.so.0.6: cannot open shared object file: No such file or directory ================================================================================REQUIRED process [moveit_setup_assistant-2] has died! process has died [pid 6694, exit code 127, cmd /opt/ros/noetic/lib/moveit_setup_assistant/moveit_setup_assistant __name:=moveit_setup_assistant __log:=/home/zjh/.ros/log/513e5cbe-09c0-11ee-a43a-e7f821379d26/moveit_setup_assistant-2.log]. log file: /home/zjh/.ros/log/513e5cbe-09c0-11ee-a43a-e7f821379d26/moveit_setup_assistant-2*.log Initiating shutdown! ================================================================================ [moveit_setup_assistant-2] killing on exit [rosout-1] killing on exit [master] killing on exit shutting down processing monitor... ... shutting down processing monitor complete done
这段代码看起来像是一段 ROS 的启动代码,其中包括了 moveit_setup_assistant 节点的启动过程,但是出现了一个错误:“libfcl.so.0.6: cannot open shared object file: No such file or directory”。这个错误可能是因为缺少了 libfcl 库导致的,需要检查是否已经安装了 libfcl 库,如果没有安装则需要安装。
阅读全文