Skip to content
目录

scrollBar

Scroll bar component

Basic usage

height Set the height of the scrolling area

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
html
<template>
  <dk-scrollbar height="200px">
    <div class="content">
      <div class="item" v-for="item in 20" :key="item">{{item}}</div>
    </div>
  </dk-scrollbar>
</template>
<style lang="scss" scoped>
  .item {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    margin: 10px;
    text-align: center;
    border-radius: 4px;
    background: rgba($color: #1cb1a4, $alpha: 0.5);
    color: #fff;
  }
</style>
展开

Horizontal scrolling

When the width of the element is greater than the width of the scrolling area, the scrollbar will automatically appear as a horizontal scrollbar.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
html
<template>
  <dk-scrollbar height="200px">
    <div class="content">
      <div class="item" v-for="item in 20" :key="item">{{item}}</div>
    </div>
  </dk-scrollbar>
</template>
<style lang="scss" scoped>
  .content {
    width: fit-content;
    display: flex;
    .item {
      width: 50px;
      height: 50px;
      display: flex;
      margin: 10px;
      align-items: center;
      justify-content: center;
      text-align: center;
      border-radius: 4px;
      background: rgba($color: #1cb1a4, $alpha: 0.5);
      color: #fff;
    }
  }
</style>
展开

v-dk-scroll instructions

Setting the v-dk-scroll instruction can also achieve scrolling style, with the same attributes and components.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
html
<template>
  <div v-dk-scroll="true" height="200px">
    <div class="item" v-for="item in 20" :key="item">{{item}}</div>
  </div>
</template>
<style lang="scss" scoped>
  .item {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50px;
    margin: 10px;
    text-align: center;
    border-radius: 4px;
    background: rgba($color: #1cb1a4, $alpha: 0.5);
    color: #fff;
  }
</style>
展开

attribute

parameterexplaintypeOptional valuesDefault value
heightScrolling area heightstring--
widthScrolling area widthstring--
bar-widthScroll bar widthstring-6px
track-colorScroll bar track colorstring-transparent
thumb-colorScroll bar slider colorstring-#c1c1c1
thumb-radiusScroll bar slider rounded cornersstring-4px
v-dk-scrollinstructionsboolean-false

Slots

nameexplain
defaultScroll Area Content

event

Event NameexplainCallback Arguments
scrollTriggered when the scroll bar scrolls({ scrollTop: number, scrollTop: number}): => void

Contributors