user12410550
user12410550

Reputation:

How can I call a method to a component prop - VueJS?

I'm trying to format a prop with a method that I've created. Is it possible?

I'm looking for something like this:

My component:

props:{
      title: String,
      min: String,
      formatedDate: this.formateDate(formatedDate)
}

Where I call this component the date is started as a empty string, but I change that value by a date-picker.

Is it possible? Thanks a lot!

Upvotes: 0

Views: 31

Answers (1)

Boussadjra Brahim
Boussadjra Brahim

Reputation: 1

You could create a computed property based on that prop which uses the method:

props:{
      title: String,
      min: String,
      date: String
},

computed:{
    formatedDate(){
       return this.formateDate(this.date)
    }
}

Upvotes: 1

Related Questions