react的 Objects are not valid as a React child (found: object with keys {name, content, time}).问题

问题原因:无法直接赋值数组到html里,需要用map等方法进行渲染

//错误方法
function App(){
    let vm = [{num:1},{num:2}]
    return (
        
{vm}
) } //正确方法 function App(){ let vm = [{num:1},{num:2}] return (
{myArray.map((item,index)=>{ {item.num} })}
) }

你可能感兴趣的:(react,react.js,前端,javascript)