• 引入
  • 代码演示
    • 基本
    • 格式化
    • 步长
    • 禁用
    • 范围
    • 边界值
  • API
    • Slider Props

    Slider 滑块

    Scan me!

    引入

    1. import { Slider } from '@didi/mand-mobile'
    2. Vue.component(Slider.name, Slider)

    代码演示

    基本

    Slider 滑块 - 图2

    1. <template>
    2. <div class="md-example-child md-example-child-slider">
    3. <md-slider v-model="quantity"></md-slider>
    4. </div>
    5. </template>
    6. <script>
    7. import {Slider} from 'mand-mobile'
    8. export default {
    9. name: 'slider-demo',
    10. components: {
    11. [Slider.name]: Slider,
    12. },
    13. data() {
    14. return {
    15. quantity: 25,
    16. }
    17. },
    18. }
    19. </script>
    20.  

    格式化

    Slider 滑块 - 图3

    1. <template>
    2. <div class="md-example-child md-example-child-slider">
    3. <md-slider v-model="quantity" :format="format"></md-slider>
    4. </div>
    5. </template>
    6. <script>
    7. import {Slider} from 'mand-mobile'
    8. export default {
    9. name: 'slider-demo',
    10. components: {
    11. [Slider.name]: Slider,
    12. },
    13. data() {
    14. return {
    15. quantity: 50,
    16. }
    17. },
    18. methods: {
    19. format(val) {
    20. return '¥' + val
    21. },
    22. },
    23. }
    24. </script>
    25.  

    步长

    Slider 滑块 - 图4

            <template>
      <div class="md-example-child md-example-child-slider">
        <md-slider v-model="bucket" :step="10"></md-slider>
        </div>
    </template>
    
    <script>
    import {Slider} from 'mand-mobile'
    
    export default {
      name: 'slider-demo',
      components: {
        [Slider.name]: Slider,
      },
      data() {
        return {
          bucket: 10,
        }
      },
    }
    
    </script>
    
          

    禁用

    Slider 滑块 - 图5

            <template>
      <div class="md-example-child md-example-child-slider">
        <md-slider v-model="quantity" disabled></md-slider>
        </div>
    </template>
    
    <script>
    import {Slider} from 'mand-mobile'
    
    export default {
      name: 'slider-demo',
      components: {
        [Slider.name]: Slider,
      },
      data() {
        return {
          quantity: 50,
        }
      },
    }
    
    </script>
    
          

    范围

    Slider 滑块 - 图6

            <template>
      <div class="md-example-child md-example-child-slider">
        <md-slider v-model="range" range></md-slider>
        </div>
    </template>
    
    <script>
    import {Slider} from 'mand-mobile'
    
    export default {
      name: 'slider-demo',
      components: {
        [Slider.name]: Slider,
      },
      data() {
        return {
          range: [25, 50],
        }
      },
    }
    
    </script>
    
    
          

    边界值

    Slider 滑块 - 图7

            <template>
      <div class="md-example-child md-example-child-slider">
        <md-slider v-model="range" :min="15" :max="80" range></md-slider>
        </div>
    </template>
    
    <script>
    import {Slider} from 'mand-mobile'
    
    export default {
      name: 'slider-demo',
      components: {
        [Slider.name]: Slider,
      },
      data() {
        return {
          range: [25, 50],
        }
      },
    }
    
    </script>
    
          

    API

    Slider Props

    属性说明类型默认值备注
    v-model双向绑定的值, 当开启range时, 其值为数组形式number, number[]0-
    disabled是否禁用滑块Booleanfalse-
    min可拖动的最小值number0-
    max可拖动的最大值number100-
    step步长number1-
    range是否启动双向拖动Booleanfalse-
    format显示文本的格式化函数Function(val) => {return val}-