使用computed计算,无需在data中再次定义
用法一:computed:{
endTime : {
get(){
let a = moment(`${this.date} ${this.startTime}`).format('YYYY-MM-DD HH:mm:ss')
let endTimeCalc = moment(a).add(this.duration,'minutes').format("HH:mm")
return endTimeCalc
},
set(val){
this.endTime = val
}
},
},
用法二:
computed:{
form () {
return {
title: this.title,
mark: this.mark,
date: this.date,
}
},
repeatVal() {
if (this.repeat == "Daily")
return "Day"
else if (this.repeat == "Weekly")
return "Week"
else if (this.repeat == "Monthly")
return "Month"
else if (this.repeat == "Yearly")
return "Year"
else
return "Day"
},
},
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)