<text style="padding-right: 10px; color: #333; font-size: 28px" slot="value">{{birthdayDate}}</text>
這里名稱,不需要定義(實際是函數名)
// 時間戳轉日期
add0 (m) {
return m < 10 ? '0' + m:m
},
getDate (item) {
var time = new Date(item)
var year = time.getFullYear()
var month = time.getMonth() + 1
var date = time.getDate()
return year + '-' + this.add0(month) + '-' + this.add0(date)
}
重構:
computed: { birthdayDate() { return this.getDate(this.user.birthday) } }
注意:birthdayDate 是轉換過的名稱,this.getDate(this.date) 轉換函數內的名稱是原有的名稱
-------------------------------------
轉時間戳
getTimestamp (mytime){
let dateTmp = mytime.replace(/-/g,'/')
return Date.parse(dateTmp)
},