0.0.6 • Published 4 years ago

v-input-check v0.0.6

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

介绍

实时校验input输入框的值vue插件

在线体验demo

安装

npm

  npm i v-input-check -S

将插件安装到vue

    import Vue from 'Vue'
    import VInputCheck from 'v-input-check'
    
    Vue.use(VInputCheck)

cdn

    <script src="dist/vue.min.js"></script>
    <script src="https://unpkg.com/v-input-check"></script>
    
    Vue.use(VInputCheck)

使用

    <input type="text" :value="price" v-input-check:positive="{ change, DpLen: 1 }" />
    const app = new Vue({
        el: '#app',
        data () {
            return {
                price: ''
            }
        },
        methods: {
            change: (value, data) => {
                this.price = value
            }
        }
    })

类型

  • positive - 正数
  • positiveInteger - 正整数
  • negative - 负数
  • negativeInteger - 负整数
  • integer - 整数
  • number - 数字(不能输入小数点、+、-符号)
  • anyNumber - 所有数字类型
  • zh - 中文
  • en - 英文
  • en.lowercase - 英文小写
  • en.upperCase - 英文大写写
  • group - 组合

options

类型: Object

    <input type="text"  v-input-check:positive="options" />
参数类型说明可选值默认值
changefunction回调函数, function(value, data) {}--
DpLennumber保留小数点的长度,只对positive、negative、anyNumberl类型有效-2
canWritePlusboolean是否可以输入+号,只对positive、positiveInteger、integer、anyNumber、类型有效false/truefasle
extraany额外字段,将会在change事件中返回给你,对你处理列表时可能有用--
grouparray可组合可输入的字符,只对group类型有效。例如"@", "-", "_", "0-9", "a-z", "A-Z"--