我设置了两个对象来模拟一些数据。我想在页面上打印两个元素,但是codePen不会显示任何错误,为什么它不会输出到页面上。
应用程序应输出两个h1元素,它们与我分配给的对象相对应。不要以为我需要在那兴起任何州。仅使用obj和obj2中的道具
谢谢。
<div id="root">
</div>
let obj = {
firstName: "Bobby",
lastName: "Lee",
};
let obj2 = {
firstName: "Priscilla",
lastName: "Young",
};
function Element(props) {
return (
<h1> Welcome back {props.identification.firstName} {props.identification.lastName} !</h1>;
);
}
function App() {
return (
<div>
<Element identification={obj} />
<Element identification={obj2} />
</div>
);
}
ReactDOM.render(<App />, document.getElementById('root'));
尝试此
function Element(props) {
return (
<h1> Welcome back {props.identification.firstName} {props.identification.lastName} !</h1>
);
}