要接收父组件传递的displayPlatform
属性并且不报错,你可以在子组件的函数参数中添加对应的类型定义,并使用props.displayPlatform
来获取该属性的值。例如:
const BrandProduct: React.FC<{ displayPlatform: string }> = (props) => {
console.log(props.displayPlatform, 'duhao____displayPlatform');
// 其他代码...
};
通过这样的方式,你可以在子组件中访问到父组件传递的displayPlatform
属性,并避免报错。
内容由零声教学AI助手提供,问题来源于学员提问