在没有 props 参数的情况下访问函数组件中的子组件
我创建了一个如下所示的类:
const Button = ({href, className, rippleColor, type}) => {
...
}
我正在使用这样的组件:
<Button rippleColor={'#ff0000'} type={'primary'} className={'my-4'}>Test</Button>
现在我想访问组件的 props.children 而不切换 ({href, className,rippleColor, type})
到 (props)
有办法做到这一点吗?
i've created a class that looks like this:
const Button = ({href, className, rippleColor, type}) => {
...
}
i'm using the component like this:
<Button rippleColor={'#ff0000'} type={'primary'} className={'my-4'}>Test</Button>
now i want to get access to the props.children of the component without switching ({href, className, rippleColor, type})
to (props)
is there a way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,只需将
children
添加到您的解构中,Yes, simply add
children
to your destructuring,