提问者:小点点

如何使用AntD抽屉在挂载的div底部滚动


通过阅读文档,我可以使用属性BodyStyle={{}}更改正文的样式。

当你打开抽屉时,我希望卷轴始终处于仰视状态?我怎样才能做到这一点呢?身体的高度将是动态的,取决于身体内的内容。

  <Drawer
        title="Basic Drawer"
        placement="right"
        closable={false}
        onClose={onClose}
        visible={visible}
      >
        <p>Some contents...</p>
        <p>Some contents...</p>
        <p>Some contents...</p>
        ....
      </Drawer>

共1个答案

匿名用户

可以使用afterVisibleChange事件按DOM滚动。使用className道具制作唯一类进行查询

 <Drawer
    title="Basic Drawer"
    placement="right"
    closable={false}
    onClose={onClose}
    visible={visible}
    afterVisibleChange={(visible)=>{
           if(visible){
                   document.body.querySelector('.demo .ant-drawer-body').scrollTo(0,9999)
           }
    } }
    className='demo'

这里有