Skip to Content
组件Scrollbar

Scrollbar

ScrollbarScrollView 的视觉搭档。

Scrollbar
Scrollbar 终端效果图
Scrollbar 的终端效果图

最小示例

let bar = Scrollbar::new(ScrollbarOrientation::VerticalRight) .content_length(200) .viewport_length(20) .position(self.offset) .on_scroll(Message::ScrollTo) .build();

关键 builder 方法

  • Scrollbar::new(...)
  • .content_length(...)
  • .viewport_length(...)
  • .position(...)
  • .symbols(...)
  • .thumb_style(...).track_style(...)
  • .on_scroll(...)

State 对象

如果你要显式维护 position 和 content length,就用 ScrollbarState

let state = ScrollbarState::new(200) .with_position(40) .with_viewport_content_length(20); let bar = Scrollbar::new(ScrollbarOrientation::VerticalRight) .state(state) .build();

去哪里看真实用法

Last updated on