在src下新建index.js:
import React from "react";
import ReactDom from "react-dom";
const list = [
{name:"大虎",count:2},
{name:"小虎",count:4},
{name:"大虾",count:1},
{name:"小虾",count:5},
{name:"大狗",count:3}
];
ReactDom.render(<ul>{
list.map(item=>{
return <li>{item.name+item.count+"只"}</li>
})
}</ul>,document.querySelector("#root"));
注意:
1.render的第一个参数为jsx
2.render的第二个参数是存放渲染数据的元素