反应三个光纤传递函数参数



我制作了一个函数,根据值返回材料

function MyMat(height){
if(height > 2) {
return (<meshStandardMaterial color="#878787" flatShading={true} />)
} 
else if(height > 1) {
return (<meshStandardMaterial color="#674942" flatShading={true} />)
}
return (
<meshStandardMaterial color="black" flatShading={true} />
)
}

当我在画布上称之为时

<MyMat height = {4} />

它工作,但值4(高度(没有通过,我怎么能通过它?

您需要将高度写为对象道具,而不是值。用MyMat({height})替换MyMat(height)