console
new Vue({
el: '#app',
data: {
cash3: '',
cash4: '',
cash5: '',
},
methods: {
onInput5 (ev) {
this.cash5 = window.sUtils.rgAllowInteger(ev.target.value, 5)
},
onInput3 (ev) {
this.cash3 = window.sUtils.rgAllowInteger(ev.target.value, 3, '+')
},
onInput4 (ev) {
this.cash4 = window.sUtils.rgAllowInteger(ev.target.value, 4, '-')
}
},
template: `
<div>
<h2>Vue当中测试整型输入限制</h2>
<label>最多不超过5位的正负整数:</label>
<input v-model="cash5" @input="onInput5" />
<hr>
<label>最多不超过3位的正整数:</label>
<input v-model="cash3" @input="onInput3" />
<hr>
<label>最多不超过4位的负整数:</label>
<input v-model="cash4" @input="onInput4" />
</div>
`
})
<div id="app"></div>