import React, { useRef, useEffect, useState } from 'react' const TimeShaft = React.forwardRef((props, ref) => { const sizeRef = useRef(); const timeShaftRef = useRef(); const timeShaftContentRef = useRef(); const [move, setTranslateY] = useState(false); const { data = [], time = "time", type = "type", name = "name", detail = "detail" } = props //获取组件高度 const tableSetting = () => { //组件实际高度 let comHeight = timeShaftRef.current.clientHeight; let contentHeight = timeShaftContentRef.current.clientHeight; let slate = comHeight < contentHeight; setTranslateY(slate) } useEffect(() => { //监听父级宽度变化 let innerWindow = sizeRef.current.contentDocument.defaultView; innerWindow.addEventListener("resize", tableSetting); tableSetting(); return () => { innerWindow.removeEventListener("resize", tableSetting); } }, []) return (