项目作者: joseluisq

项目描述 :
A custom input number component for Vue.js 2
高级语言: Vue
项目地址: git://github.com/joseluisq/vue-input-number.git
创建时间: 2017-10-25T20:09:50Z
项目社区:https://github.com/joseluisq/vue-input-number

开源协议:

下载


vue-input-number npm npm JavaScript Style Guide

A custom input number component for Vue.js 2.

Install

Yarn

  1. yarn add vue-input-number --dev

NPM

  1. npm install vue-input-number --save-dev

Prerequisites

Usage

  1. <template>
  2. <input-number
  3. :step="1"
  4. :min="10"
  5. :max="100"
  6. :maxlength="3"
  7. :inputclass="'v-input-number-input'"
  8. @onInputNumberChange="onChange"></input-number>
  9. </template>
  10. <script>
  11. export default {
  12. methods: {
  13. onChange (value) {
  14. console.log(value)
  15. }
  16. }
  17. }
  18. </script>

In your entry app:

  1. const Vue = require('vue')
  2. Vue.component('vue-input-number', require('vue-input-number'))
  3. const app = new Vue({
  4. el: '#app'
  5. })

For more detailed example check out the app directory.

Attributes

  • value: Add a default value to input.
  • step: Step value for increment and decrement the input number value.
  • min: Minimum value for input number. min is only used as a placeholder if placeholder is empty.
  • max: Maximum value for input number.
  • maxlength: Maxlength for the input number.
  • keydown: Enable keydown for increment or decrement value.
  • mousedown: Enable mousedown for increment or decrement value.
  • integer: Enable integer value only.
  • placeholder: Set a input placeholder. If placeholder has some value then min is not used as a placeholder.
  • inputclass: Set a diferent class for the input element. For example, if you use Bootstrap default input class you can set :inputclass="'form-control'" to use form-control class in the input element.

Events

@onInputNumberChange

Event is fired when value is changed.

License

MIT license

© 2018 José Luis Quintana