0
道具是什么意思?代码:ReactJS中的'...道具'是什么意思?
export default class NavItem extends React.Component {
constructor() {
super();
}
render() {
const { router, index, to, children, ...props } = this.props;
let isActive = false;
if (router.isActive('./', true) && index) {
isActive = true
children
我想这是实际元素的孩子,但...props
这是什么意思?
谢谢。
在该上下文中使用
的可能的复制[什么的三个点中反应过来怎么办?(http://stackoverflow.com/questions/31048953/what-does-the-three-dots-in-react-do) –
'const {children,... props} = this.props;'意思是将props.children分配给儿童,将this.props的所有剩余值分配给道具。 – elmeister