SOURCE

console 命令行工具 X clear

                    
>
console
new Vue({
    el: '#app',
    data: {
        cash1: '',
        cash2: '',
        cash3: '',
        cash4: '',
    },
    methods: {
        onInput1 (ev) {
            this.cash1 = sUtils.rgAllowFloat(ev.target.value)
        },
        onInput2 (ev) {
            this.cash2 = sUtils.rgAllowFloat(ev.target.value, 3, '', 4)
        },
        onInput3 (ev) {
            this.cash3 = sUtils.rgAllowFloat(ev.target.value, 1, '+')
        },
        onInput4 (ev) {
            this.cash4 = sUtils.rgAllowFloat(ev.target.value, 4, '-')
        },
    },
    template: `
        <div>
            <h2>Vue当中测试浮点型输入限制</h2>
            <label>默认小数位不超过2位:</label>
            <input v-model="cash1" @input="onInput1" />
            <hr>
            <label>整数位限制4位,小数位3位:</label>
            <input v-model="cash2" @input="onInput2" />
            <hr>
            <label>整数不限,小数位1位,正数:</label>
            <input v-model="cash3" @input="onInput3" />
            <hr>
            <label>整数不限,小数位4位,负数:</label>
            <input v-model="cash4" @input="onInput4" />
        </div>
    `
})
<div id="app"></div>

本项目引用的自定义外部资源