reactjs - 调整 react-beautiful-dnd 的大小
问题描述
是否可以调整可放置容器的高度?我尝试了内联样式
<Droppable droppableId="list" style={{ height: 200 }}>
但没有产生预期的结果。我的期望是容纳可拖动项目的容器可以调整到一定的高度 x 并且可拖动项目的溢出将是可滚动的。我还尝试<DragDropContext onDragEnd={this.onDragEnd}>
使用以下div
标签进行包装:
<div style={{ height: 200 }}>
https://codesandbox.io/s/using-react-beautiful-dnd-with-hooks-qnez5
解决方案
您也可以提供内联样式和条件样式。如下面的代码所示它的内联样式。
<Droppable
droppableId={`${laneItem.Value}`}
type="TASK"
key={`droppable-${laneItem.Value}`}
>
{(provided) => (
<div
id={laneItem.Value}
ref={provided.innerRef}
{...provided.droppableProps}
key={`droppable-div-${laneItem.Value} - ${index + 1}`}
style={{ height: '200px' }}
>
这里是条件样式,
<Droppable
droppableId={`${laneItem.Value}`}
type="TASK"
key={`droppable-${laneItem.Value}`}
>
{(provided) => (
<div
id={laneItem.Value}
ref={provided.innerRef}
{...provided.droppableProps}
key={`droppable-div-${laneItem.Value} - ${index + 1}`}
styles={true ? bigHeight : smallHeight}
>
其中 big-Height 和 small-Height 是 const。
const big-Height: any = {
root: {
height: "200px"
}
}
推荐阅读
- javascript - 发送帖子时它返回:流意外结束
- c++ - SystemParametersInfo 将背景设置为纯色而不是实际设置图片
- html - 应用于一张桌子的 CSS 不适用于另一张桌子
- python - PySpark:无法创建小型数据框
- google-apps-script - Add cell copy to existing function
- javascript - 即使我试图保持它,Textarea也会失去焦点
- microsoft-cognitive - Azure 认知服务容器与云之间的任何模型质量差异
- wpf - 将元素绑定到不同的 DataContext 属性
- python - Python为多个列表元素赋值
- rust - include_bytes!() 可以用于自定义结构吗?