我是 react 新手,我不知道如何从React map 函数中获取每个项目的宽度。它只是返回一个没有 js 函数的 React 元素。
例如:
this.props.children.map((child, index) => {
console.log(child.clientWidth);
})
请指教。 谢谢。
最佳答案
使用返回
this.props.children.map((child, index) => {
console.log(child.clientWidth);
return child.clientWidth
})
关于dictionary - react : how to get item width from map function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34760931/