Existing data 1 shipTypes
{
"Destroyer": "驅逐艦",
"AirCarrier": "航空母艦",
"Battleship": "主力艦",
"Cruiser": "巡洋艦"
}
and data 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 structure (pug syntax)
ul
li
img {{shipTypeImages.image}}
span {{shipTypes.value}}
How do I match the Key values of two data (such as "Destroyer") with the data, as shown in the following example?
Destroyer
Aircraft carrier
Battleship
Cruiser
Thanks!
伊谢尔伦2017-05-18 11:04:34
Two arrays foreach loop to form a new array to render to the page
Or use computed properties
巴扎黑2017-05-18 11:04:34
let ships = Object.keys(shipTypes).map((type) => {
return {
type,
name: shipTypes[type],
image: shipTypeImages[type].image
}
})
console.log(ships);
...