Loop object that in the array and in the another object

后端 未结 2 1776
鱼传尺愫
鱼传尺愫 2021-01-25 20:49

i have the following structure. I need to get Internal value and through in the React. I think i need to get an array of values, for example: [\'Bitcoin\', \'Etherium\'...] and

2条回答
  •  佛祖请我去吃肉
    2021-01-25 21:18

    Do it like this

    import React from 'react'
    
    export default class YourComponent extends React.Component {
        render() {
            let arr = [
                {
                    "CoinInfo": {
                        "Id": "1182",
                        "Name": "BTC",
                        "FullName": "Bitcoin",
                        "Internal": "BTC",
                        "ImageUrl": "/media/19633/btc.png",
                        "Url": "/coins/btc/overview"
                    }
                },
                {
                    "CoinInfo": {
                        "Id": "7605",
                        "Name": "ETH",
                        "FullName": "Ethereum",
                        "Internal": "ETH",
                        "ImageUrl": "/media/20646/eth_logo.png",
                        "Url": "/coins/eth/overview"
                    }
                }
            ]
    
            let newArr = arr.map((data) => {
                return data.CoinInfo.FullName
            })
            console.log('new array', newArr);
            return (
                
    ) } }

提交回复
热议问题