Giter Site home page Giter Site logo

joseluisq / vue-input-number Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 6.0 58 KB

A custom input number component for Vue.js 2

Home Page: http://cdpn.io/gGVRBP/

TypeScript 2.04% Vue 79.37% HTML 3.28% JavaScript 15.32%
vue input-number component input custom-input number-input

vue-input-number's Introduction

vue-input-number npm npm JavaScript Style Guide

A custom input number component for Vue.js 2.

Install

Yarn

yarn add vue-input-number --dev

NPM

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

Prerequisites

Usage

<template>

    <input-number
        :step="1"
        :min="10"
        :max="100"
        :maxlength="3"
        :inputclass="'v-input-number-input'"
        @onInputNumberChange="onChange"></input-number>

</template>

<script>
  export default {
    methods: {
        onChange (value) {
            console.log(value)
        }
    }
  }
</script>

In your entry app:

const Vue = require('vue')

Vue.component('vue-input-number', require('vue-input-number'))

const app = new Vue({
  el: '#app'
})

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

vue-input-number's People

Contributors

baronkoko avatar joseluisq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vue-input-number's Issues

Default value not :min

Hehe sorry bothering again, related to the merged PR with :placeholder improvement, emerged another issue: default value is taken from min default data, and in my case it is not showing the placeholder, just if I delete the min value but it re-appears:

mar-19-2018 11-48-07

Decimal issue, not all countries are using "." for decimal

What about for example "4,6" instead of "4.6". Also a problem with length. If you want to have a decimal number and say like this:

min = 1
max = 300
length = 4

and then type in 400 it is only changed to max when you do blur, and second if you want a number with three digits and dot you have to put in length 4 because "." is also taken into consideration.

Like some big bugs. You should look into that.

How do i get the value from external js ?

Hello! Excuse me, how can i access the value from parent js-file?
i importing your component like this

var app = new Vue({
	el: '#app',
	components: {
		'counter': vueNumber
	},

am i doing something wrong? Thank you.

set step=0.7 then get wrong data

I set the step length to 0.7, set the initial value to 1, click add button for twice, get the wrong data。
Forgive my weak English

Looking for maintainer

I don't have time to maintain this project. If someone is interested on it. Let me to know.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.