javascript - CSS轮播/幻灯片动画通过数组元素
问题描述
我有数据从我的后端发送到我的前端,然后数据被解析并显示到一个表中。但是,在数组中元素的最大数量时,表格中的行太多,并且超出了我需要表格所在的区域。所以旋转木马/幻灯片动画将是最好的选择,我想成为能够一次显示 4 行元素,然后在接下来的 4 行中调用幻灯片动画。我不太确定如何在设置表数据的函数的当前迭代中执行此操作。有人可以指出我正确的方向吗?
function FormTable(props){
/**
* props = allStations
*/
console.log(props.data)
return(
<table className="form__table">
<div className="form__table-parentDiv">
<thead>
<tr>
<th className="form__table-header">Departing Station</th>
<th className="form__table-header">Arriving Station</th>
<th colSpan={2} className="form__table-header">Departure Time</th>
</tr>
</thead>
<tbody>
{
props.data.map( (stationIndex) => {
// console.log(stationIndex);
let cells = [];
for(let i = 1; i < stationIndex.length; i++){
cells.push(
<React.Fragment>
<td className="form__table-stations"> {stationIndex[i].station} </td>
<td className="form__table-stations"> {stationIndex[i].destination} </td>
<td className="form__table-arrivals"> {stationIndex[i].firstArrival} </td>
<td className="form__table-arrivals"> {stationIndex[i].secondArrival} </td>
</React.Fragment>
);
}
return <tr className="form__table-row" >{ cells }</tr>
})
}
</tbody>
</div>
</table>
)
}
解决方案
推荐阅读
- asp.net - 使用文本框中的值在 asp.net Web 表单中使用 WEBAPI PUT 方法
- javascript - Example1 和 Example2 有什么区别?
- javascript - 从其他监听器调用监听器
- python - 如何在 python 中循环所有这些代码
- reactjs - 使用 thunk 处理 onClick 事件。是不是更有效率?
- javascript - 如何在 JavaScript 中使用字符串 [] 将 Object {{},{}} 中的两个 Object 转换为 Array
- azure - Start-AzAutomationRunbook 不断失败,并显示“Start-AzureRmAutomationRunbook:找不到与参数名称“等待”匹配的参数。”
- reactjs - 使用 immer 将 Redux 状态数组替换/更改为其他数组
- pandas - 尝试使用分类变量运行逻辑回归模型,但无法从对象更改 dtype
- clojure - 无头运行时如何跟踪 Clojure Leiningen REPL?