简体   繁体   中英

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM