Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type:integer的判断是不是有问题? #265

Open
TY-The-King opened this issue Mar 16, 2021 · 3 comments
Open

type:integer的判断是不是有问题? #265

TY-The-King opened this issue Mar 16, 2021 · 3 comments

Comments

@TY-The-King
Copy link

/js文件
data{
agerules:[
{
type:"integer",
trigger:"change",
message:'年龄必须为整数!'
},
{
min: 1,
max: 3,
message: '超出范围年龄:0-99!',
trigger:"change"
},
{
required: true,
trigger:"change",
message:'年龄不能为空'
}
],
}
我在js这样写,然后前端输入年龄时,输入整数20,30,33这些全都报错,说不是整数。该怎么解决呢?
是我的写法出错了嘛?

@betgar
Copy link

betgar commented Mar 25, 2021

估计你需要把value先transform成数字,parseInt(age, 10)

{
 rules: [
  {
    transform(value) {
      return parseInt(value, 10)
    }
  }
 ]
}

@sunft1996
Copy link

估计你需要把value先transform成数字,parseInt(age, 10)

{
 rules: [
  {
    transform(value) {
      return parseInt(value, 10)
    }
  }
 ]
}

正解

@crazyair
Copy link

react-component#2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants