diff --git a/components/Collapse.js b/components/Collapse.js index 69ef59ebca7..dd36f14fe28 100644 --- a/components/Collapse.js +++ b/components/Collapse.js @@ -26,9 +26,9 @@ const Collapse = props => { }) /** - * 折叠 - * @param {*} element - */ + * 折叠 + * @param {*} element + */ const collapseSection = element => { const sectionHeight = element.scrollHeight const sectionWidth = element.scrollWidth @@ -51,9 +51,9 @@ const Collapse = props => { } /** - * 展开 - * @param {*} element - */ + * 展开 + * @param {*} element + */ const expandSection = element => { const sectionHeight = element.scrollHeight const sectionWidth = element.scrollWidth @@ -82,13 +82,24 @@ const Collapse = props => { collapseSection(ref.current) } // 通知父组件高度变化 - props?.onHeightChange && props.onHeightChange({ height: ref.current.scrollHeight, increase: props.isOpen }) + props?.onHeightChange && + props.onHeightChange({ + height: ref.current.scrollHeight, + increase: props.isOpen + }) }, [props.isOpen]) return ( -
- {props.children} -
+
+ {props.children} +
) } Collapse.defaultProps = { isOpen: false }