mr-wang-input-number

    1.0.2 • Public • Published

    真正的限制数字输入框的输入内容,并不是仅仅在blur失去焦点的时候

    1、组件绑定keyup和keydown事件
    <input @keyup.native="keyUpEvent" @keydown.native="keyDownEvent" />

    2、实例化

    this.inputNumberClient = new InputNumber({
    	isNegative: true, //是否能输入负数 
    	precision: 2, //精确位数
    });

    3、绑定事件

    keyDownEvent(e) {
    	this.inputNumberClient.keyDownEvent(e)
    };
    keyUpEvent(e) {
    	this.inputNumberClient.keyUpEvent(e)
    }

    每个keyup和keydown事件都有个格式化后的值回调,回调是当前Dom的target

    this.inputNumberClient.keyUpEvent(e, (target) => {
    	console.log(target.value)
    });

    Install

    npm i mr-wang-input-number

    DownloadsWeekly Downloads

    1

    Version

    1.0.2

    License

    ISC

    Unpacked Size

    10.3 kB

    Total Files

    3

    Last publish

    Collaborators

    • mr-wang