setMarks(Json) {
const result = Json.reduce((arr, it) => {
arr.push({
id: it.id,
name: it.IPBoxName,
addr: it.IPBoxAddr,
lnglat: [+it.Lng, +it.Lat],
color: {
0: `rgba(165,165,165, .4)`,
1: `rgba(66,185,131, .4)`,
2: `rgba(244,81,108, .4)`,
3: `rgba(244,81,108, .4)`,
4: `rgba(144,144,144, .4)`
}[it.status],
type: 'circle',
speed: 0.5
})
return arr
}, [])
中
color: {
0: `rgba(165,165,165, .4)`,
1: `rgba(66,185,131, .4)`,
2: `rgba(244,81,108, .4)`,
3: `rgba(244,81,108, .4)`,
4: `rgba(144,144,144, .4)`
}[it.status],
根据status的值跟0~4进行匹配,选择对应颜色存入color,请问这是属于javascript的什么语法?网上查了很久没查到
json 取值
问题已经知道,是传入动态键在固定字典取值返回赋值
传入动态键在固定字典取值返回赋值