- 购物车开发中,碰到input框type=number输入的内容中可以输入.±等符号
- 如图所示
- 看了下vant的底层
<input type="tel" inputmode="numeric" value="1" class="van-field__control">
这里是引用 type=“tel” 主要是使用了inputmode属性,当然你也可以使用type=“text”
当然还要使用
onInput(e, index, item) {
this.cartList[index].count = e.target.value
return (item.count = e.target.value.replace(/^0{1,}/g, ''))
},
如果使用type=text inputmode=“decimal”
至于type=text inputmode=“numeric” 还没有测试,有待测试
`onInput(e, index, item) {
this.cartList[index].count = e.target.value
return (item.count = e.target.value,replace(/\D/g,'').replace(/^0{1,}/g, ''))
},`