mathnabit
mathnabit

Reputation: 370

A decimal variable in data of vuejs component

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 ?

Upvotes: 3

Views: 984

Answers (1)

Boussadjra Brahim
Boussadjra Brahim

Reputation: 1

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
  }
 }
}

Upvotes: 3

Related Questions