[英]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)
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.