[标准]类组件props批量数据传参

zhuanbike 2022-1-1 801

***
class Com extends React.Component{
    render(){
        return(
     <div>我们在这里传以下参数:{this.props.name1} {this.props.name2} {this.props.name3} {this.props.name4} {this.props.others5} </div>  //this.props.后面的内容是自定义属性值
                )
     }
}
let Myapi={
name1="第1个参数",
name2="第2个参数",
name3="第3个参数",
name4="第4个参数",
others5="第5个参数",
}
ReactDom.render(<Com {...Myapi}/> document.getElementById("theID"));  // <com/>单标签,里面...Myapi表示调用Myapi里面的参数,三个点必不可少。


最新回复 (0)
发新帖