How to render a Object in React?

后端 未结 4 860
忘了有多久
忘了有多久 2021-02-14 09:16

I want to render a Object .

My Object is:

const ObjectTest = {
        1: {
            id : 1,
            name:\'ABC\'
                 


        
4条回答
  •  不思量自难忘°
    2021-02-14 09:42

    In react you can render your wish answer in browser screen by below code

    import React from 'react';
    
    
    const ObjectTest = {
      1: {
          id : 1,
          name:'ABC'
      },
      3: {
          id: 3,
          name:'DEF'
      }
    }
    
    class App extends React.Component {
    
       constructor(props) {
          super(props);
       };
    
       render() {
          return (
             
    { Object.keys(ObjectTest).map((value,index)=>{

    id is {ObjectTest[value].id} ; name is {ObjectTest[value].name}

    }); }
    ); } } export default App;

提交回复
热议问题