在Reaction应用程序中,我在容器中动态创建新组件.当新创建的项超过容器的高度时,我希望容器可以在Y方向滚动.我不能用overflow: 'auto'来实现这个行为.有什么建议吗?

萨斯:

.v-timeline{   // parent component
    flex: 1;
    height: 100%;
    width: 100%;
    flex-wrap: nowrap;
    .v-timeline-container {   // this is our container
        .v-timeline-indicator {
            z-index: 2;
            background-color: rgb(0, 105, 185);
            width: 3px;
            position: relative;
        }
        .v-timeline-items {   // these are the new items
            .v-timeline-item {
                height: 60px;
            }
        }
    }
}

该组件:

const [gridItems, setGridItems] = useState([{ id: 'firstItemID', info: 'firstItemInfo'}]);     

const addRow = () => {
    setGridItems([
        ...gridItems, {
            id: uuidv4() ,
            info: 'doesnt matter'
        }
    ]);
}

return (
    <>
        <button  onClick={addRow}>Add Row</button>
        <div className='v-timeline-container' style={{ overflow: 'auto'}} >
            {
                gridItems.map(item => (
                <div id={`thisTimeline${item.id}`} style={{ display: 'flex', overflow: 'scroll'}} key={`thisItem${item.id}`} className="v-timeline-items v-border">
                    <Indicator id={item.id} height={60}/>
                    <div>
                        <CustomItemContainer id={item.id} info={item.info}/>
                    </div> 
                </div>
                ))
            }
        </div>

    </>

)

事情是这样开始的:

enter image description here

事情是这样发展的:

enter image description here

推荐答案

看起来你没有给集装箱设置高度. try 将容器的高度设置为固定.

.v-timeline-container{
  height: 100%;
}

Javascript相关问答推荐

如何在加载的元数据上使用juserc和await中获得同步负载?

获取加载失败:获取[.]添加时try 将文档添加到Firerestore,Nuxt 3

我无法在NightWatch.js测试中获取完整的Chrome浏览器控制台日志(log)

. NET中Unix时间转换为日期时间的奇怪行为

我可以从React中的出口从主布局调用一个处理程序函数吗?

屏幕右侧屏障上的产卵点""

您能在卸载程序(QtInsteller框架)上添加WizardPage吗?

当输入字段无效时,我的应用程序不会返回错误

<;img>;标记无法呈现图像

为什么在函数中添加粒子的速率大于删除粒子的速率?

如何在和IF语句中使用||和&;&;?

处理TypeScrip Vue组件未初始化的react 对象

如何使用抽屉屏幕及其子屏幕/组件的上下文?

Clip-Path在网页浏览器(Mozilla、Edge、Chrome)上不能正常工作,但在预览版Visual Code Studio HTML、CSS、JS上却能很好地工作

React Refs不与高阶组件(HOC)中的动态生成组件一起工作

为什么我看到的是回复,而不是我的文档?

使用createBrowserRoutVS BrowserRouter的Reaction路由

如何在每隔2分钟刷新OKTA令牌后停止页面刷新

rxjs在每次迭代后更新数组的可观察值

如何在Firebase中读取对象的特定字段?