一般来说这样写上,就可以了。但是测试输入的时候一直对不上。
经过度娘了半天,发现有一篇博客:,看一下官方说明 :
Sometimes it is necessary to transform a value before validation, possibly to coerce the value or to sanitize it in some way. To do this add a transform
function to the validation rule. The property is transformed prior to validation and re-assigned to the source object to mutate the value of the property in place.
大致意思 有时需要在验证之前转换值,可能为了某些特殊需求。为此,transform
向验证规则添加一个函数,该属性在验证之前进行转换,并重新分配给源对象,以便在适当的位置改变属性的值。
所以我们可以用 Transform
解决问题:加上:transform: (value) => Number(value)
code: [
{type: 'number', message: '请输入正确数值', trigger: '