我正在寻找一个库(反应可调整大小)。从来没有见过这种语法,而且我的google-fu很弱。
评论正在帮助我理解代码的作用,但语法是这样的,我真的不明白它是如何做到的。
// What we're doing here is getting the child of this element, and cloning it with this element's props.
// We are then defining its children as:
// Its original children (resizable's child's children), and
// A draggable handle.
return (0, _cloneElement2.default)(children, _extends({}, p, {
className: className,
children: [children.props.children, _react2.default.createElement(
_reactDraggable.DraggableCore,
_extends({}, draggableOpts, {
key: 'resizableHandle',
onStop: this.resizeHandler('onResizeStop'),
onStart: this.resizeHandler('onResizeStart'),
onDrag: this.resizeHandler('onResize')
}),
_react2.default.createElement('span', { className: 'react-resizable-handle' })
)]
}));