使用 scroller 和 stickyHeader 有什么区别?

What is the difference between using scroller and stickyHeader?

我遇到了这个 question。我看到 stickyHeader 和 scroller 的工作方式有点相同,它们都保持 header 行可见,并且侧面有一个滚动条。谁能解释一下它们之间的区别吗?

stickyHeader 小部件 使 table 头部 "stick" 到浏览器或 table 容器的顶部(如果设置了选项), window 当用户向下滚动 table;这类似于一些网站用于网站导航的粘性菜单。查看 this demo especially the last one on that page which is an example of nested tables stacking the sticky headers while you scroll down the document. There is also a css3 version of this widget,它使用 css3 转换将 table 头部定位在浏览器的顶部 window。

另一方面,滚动小部件必须复制 table header 放在 table 上方,隐藏原始 table header,然后使 table 的 tbody 可滚动,在固定高度内。因此,浏览器 window 位置不会改变用户滚动浏览 table 内容的位置,只会看到可滚动的 window 内容。如果你查看 this demo,你会看到 table body 是可滚动的,但头部不会 "stick" 到浏览器 window (除非你设置 scroller_jumpToHeader 强制 table 头部在向上滚动文档时可见。