繁体   English   中英

如何调用组件道具的方法 - VueJS?

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

我正在尝试使用我创建的方法格式化道具。 可能吗?

我正在寻找这样的东西:

我的组件:

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

在我调用此组件的地方,日期以空字符串开始,但我通过日期选择器更改了该值。

可能吗? 非常感谢!

您可以基于使用该方法的道具创建计算属性:

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

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

暂无
暂无

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

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