现有数据1 shipTypes
{
"Destroyer": "驅逐艦",
"AirCarrier": "航空母艦",
"Battleship": "主力艦",
"Cruiser": "巡洋艦"
}
和数据2 shipTypeImages
{
"Destroyer": {
"image": "http://glossary-asia-static.gcdn.co/icons/wows/current/vehicle/types/Destroyer/normal.png",
},
"AirCarrier": {
"image": "http://glossary-asia-static.gcdn.co/icons/wows/current/vehicle/types/AirCarrier/normal.png",
},
"Battleship": {
"image": "http://glossary-asia-static.gcdn.co/icons/wows/current/vehicle/types/Battleship/normal.png",
},
"Cruiser": {
"image": "http://glossary-asia-static.gcdn.co/icons/wows/current/vehicle/types/Cruiser/normal.png",
}
}
Vue DOM 结构(pug 语法)
ul
li
img {{shipTypeImages.image}}
span {{shipTypes.value}}
我如何做到两个数据的 Key 值(如 "Destroyer" )与数据匹配, 做到如下示例?
驅逐艦
航空母艦
主力艦
巡洋艦
谢谢!
兩個陣列foreach循環,組成一個新的陣列來渲染到頁面
或用計算屬性
雷雷
...