【发布时间】:2022-01-02 13:04:07
【问题描述】:
在这里我试图将 ref 属性传递给 div 但它没有发生,任何人都可以帮助我解决这个问题
const ref = useRef<HTMLDivElement>(null);
for (let curRow = 1; curRow <= props.row; curRow++) {
for (let curCol = 1; curCol <= props.col; curCol++) {
columns.push(
<div
ref={ref}
style={{ minWidth: `${minWidth}px` }}
className="el1"
id={`${curRow}${curCol}}`}
key={`${curRow}${curCol}${generateKey(curCol)}`}
>{`${curRow}${curCol}`}</div>
);
}
}```
【问题讨论】:
-
您是否想让 ref 指向 all 的 div?还是有你想要的特定 div?
-
我想引用所有的 div
标签: reactjs react-hooks ref