vant icon indicating copy to clipboard operation
vant copied to clipboard

van field组件当type传入number时,解析成的input却还是type=text

Open xsdhy opened this issue 6 years ago • 3 comments

设备 / 浏览器

Google Chrome 83.0.4103.61(正式版本) (64 位)

Vant 版本

2.8.3

Vue 版本

2.6.11

描述问题

van field组件当type传入number时,解析成的input却还是type=text 这就导致传给后端的还是字符串类型,和预期的number类型不一致

xsdhy avatar May 25 '20 13:05 xsdhy

同问

sniperZj avatar May 26 '20 08:05 sniperZj

form表单里设置无效

sniperZj avatar May 26 '20 08:05 sniperZj

input 的 type 为 number 时,在 iOS 上是无法限制输入非数字的,因此 Vant 里的 number 类型是基于 type="text" 实现的。

其次 type 代表的是用户可输入值的类型,不代表 Field 绑定的变量类型,变量类型永远为 string,可以自行转换为 number 类型。

chenjiahan avatar May 26 '20 09:05 chenjiahan