Home > Back-end >  How to save data from Firebase as a number with Vue.js
How to save data from Firebase as a number with Vue.js

Time:02-04

I use Firebase with Vue.js. Here I save to the database with this command:

saveEvent(){
  db.collection('events').add({
    title: this.title,
    content: this.content,
    start: this.start,
    end: this.end,
    split: this.split,
  })
  this.events.push(this.data)
}

Everything is saved as string, but I would like to save 'split' as a number.

Split is saved as a String

do you have any suggestions for solutions?

CodePudding user response:

try doing split: Number(this.split) to cast a string into number.

  •  Tags:  
  • Related