Stepper 步进器

Scan me!

增加,减少或修改当前数值

引入

  1. import { Stepper } from 'mand-mobile'
  2. Vue.component(Stepper.name, Stepper)

代码演示

禁用

Stepper 步进器 - 图2

  1. <template>
  2. <div class="md-example-child md-example-child-stepper md-example-child-stepper-0">
  3. <md-field>
  4. <md-field-item title="禁用">
  5. <md-stepper slot="right" disabled />
  6. </md-field-item>
  7. </md-field>
  8. </div>
  9. </template>
  10. <script>
  11. import {Stepper, Field, FieldItem} from 'mand-mobile'
  12. export default {
  13. name: 'stepper-demo',
  14. components: {
  15. [Field.name]: Field,
  16. [FieldItem.name]: FieldItem,
  17. [Stepper.name]: Stepper,
  18. },
  19. }
  20. </script>
  21.  

最小值-12,最大值18

Stepper 步进器 - 图3

        <template>
  <div class="md-example-child md-example-child-stepper md-example-child-stepper-2">
    <md-field>
      <md-field-item title="最小值-12,最大值18">
        <md-stepper slot="right" v-model="value" min="-12" max="18" />
      </md-field-item>
    </md-field>
  </div>
</template>

<script>
import {Stepper, Field, FieldItem} from 'mand-mobile'

export default {
  name: 'stepper-demo',
  components: {
    [Field.name]: Field,
    [FieldItem.name]: FieldItem,
    [Stepper.name]: Stepper,
  },
  data() {
    return {
      value: 0,
    }
  },
}

</script>

      

最小值4大于默认值

Stepper 步进器 - 图4

        <template>
  <div class="md-example-child md-example-child-stepper md-example-child-stepper-4">
    <md-field>
      <md-field-item title="最小值4大于默认值">
        <md-stepper slot="right" :min="4" />
      </md-field-item>
    </md-field>
  </div>
</template>

<script>
import {Stepper, Field, FieldItem} from 'mand-mobile'

export default {
  name: 'stepper-demo',
  components: {
    [Field.name]: Field,
    [FieldItem.name]: FieldItem,
    [Stepper.name]: Stepper,
  },
}

</script>

      

只读

Stepper 步进器 - 图5

        <template>
  <div class="md-example-child md-example-child-stepper md-example-child-stepper-1">
    <md-field>
      <md-field-item title="只读">
        <md-stepper slot="right" read-only />
      </md-field-item>
    </md-field>
  </div>
</template>

<script>
import {Stepper, Field, FieldItem} from 'mand-mobile'

export default {
  name: 'stepper-demo',
  components: {
    [Field.name]: Field,
    [FieldItem.name]: FieldItem,
    [Stepper.name]: Stepper,
  },
}

</script>

      

步进2

Stepper 步进器 - 图6

        <template>
  <div class="md-example-child md-example-child-stepper md-example-child-stepper-3">
    <md-field>
      <md-field-item title="步进2, 只允许输入整数">
        <md-stepper slot="right" v-model="value" :step="2" :min="2" is-integer />
      </md-field-item>
    </md-field>
  </div>
</template>

<script>
import {Stepper, Field, FieldItem} from 'mand-mobile'

export default {
  name: 'stepper-demo',
  components: {
    [Field.name]: Field,
    [FieldItem.name]: FieldItem,
    [Stepper.name]: Stepper,
  },
  data() {
    return {
      value: 3,
    }
  },
}

</script>

      

step为小数1.3

Stepper 步进器 - 图7

        <template>
  <div class="md-example-child md-example-child-stepper md-example-child-stepper-5">
    <md-field>
      <md-field-item title="step为小数1.3">
        <md-stepper slot="right" :step="1.3" />
      </md-field-item>
    </md-field>
  </div>
</template>

<script>
import {Stepper, Field, FieldItem} from 'mand-mobile'

export default {
  name: 'stepper-demo',
  components: {
    [Field.name]: Field,
    [FieldItem.name]: FieldItem,
    [Stepper.name]: Stepper,
  },
}

</script>

      

API

Stepper Props

属性说明类型默认值
v-model当前值Number/String-
step每次改变步数,可以为小数Number/String1
min最小值Number/String-Infinity
max最大值Number/StringInfinity
disabled禁用Booleanfalse
read-only只读Booleanfalse
is-integer只能输入整数Booleanfalse

Stepper Events

@change(currentValue)

值发生变化事件

@increase(difference)

当前值增加时触发 2.2.0+

属性说明类型
difference增加的数值Number
@decrease(difference)

当前值减少时触发 2.2.0+

属性说明类型
difference减少的数值Number