我不明白為什么這個組件不起作用這里是 img 的鏈接“因為不知何故我無法直接發布影像 [1]:https : //i.stack.imgur.com/Ax7im.png 感謝您的任何幫助在這里你有代碼:
import React from 'react';
import ReactDOM from 'react-dom';
import Postitem from "./Postitem";
const Postlist=(post,title)=>{
return (
<div>
<h1 style={{textAlign: 'center'}}>{title}</h1>
{post.map((post) =>
<Postitem post={post} key={post.id}/>)};
</div>
)};
export default Postlist;
uj5u.com熱心網友回復:
React 函陣列件只接受一個引數,即一個包含所有道具的物件。假設您在post渲染時將prop 作為陣列傳遞,將函式宣告修復為此將起作用:
const Postlist=({post,title})=>{
// component body here, as above
}
uj5u.com熱心網友回復:
檢查,這個組件的“post”變數中有什么。如果你使用“post.map”函式,那么它必須是一個陣列。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/344444.html
標籤:javascript 反应 网络 成分 类型错误
