Home > Net >  A decimal variable in data of vuejs component
A decimal variable in data of vuejs component

Time:12-13

We don't have the decimal type between the possible types to use in the data of a vuejs component (String, Number, Boolean, Array, Object, Date, Function, Symbol), so how to define a variable of this type ?

CodePudding user response:

A decimal variable is of type Number, you could define it as number then use a validator to check if it's decimal :

props:{
 price:{
   type:Number,
   validator(value){
     return value%1!==0
  }
 }
}
  • Related