我有这个json
{
[{
"status": "delivered"
}, {
"status": "delivered"
}, {
"status": "cancelled"
}, {
"status": "on Delivery"
}]
}
我试图得到“status”的总长度:“delivered”在json中我们有两个“delivered”,那么我怎么得到“delivered”的长度,也就是2,我怎么做剩下的状态
这是我的vue组件
<script>
import axios from "axios";
export default {
data() {
return {
orders: null,
};
},
created() {
axios.get("http://localhost:5000/api/orders").then((response) => {
this.orders = response.data;
});
},
};
</script>
2条答案
按热度按时间cngwdvgl1#
你可以过滤数组并获取长度:
thigvfpy2#
首先,您提供一个未格式化的JSON。我想你的意思是处理这个数组:
此外,如果您想将其他状态计入表中: