gpt4 book ai didi

javascript - react 转移 Prop ,除了一个

转载 作者:IT王子 更新时间:2023-10-29 03:07:24 25 4
gpt4 key购买 nike

React 建议 Transfer Props .整洁!

除了一个,我怎样才能转移所有?

render: function(){
return (<Cpnt {...this.propsButOne}><Subcpnt one={this.props.one} /></Cpnt>);
}

最佳答案

您可以使用以下技术来消耗一些 Prop 并传递其余的 Prop :

render() {
var {one, ...other} = this.props;
return (
<Cpnt {...other}>
<Subcpnt one={one} />
</Cpnt>
);
}

Source

关于javascript - react 转移 Prop ,除了一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35152522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com