fix: date is NaN at timeline

This commit is contained in:
reco_luan 2019-08-19 20:24:19 +08:00
parent 6ada21ecb2
commit 81d6c63321

View File

@ -6,7 +6,7 @@
<h3 class="year">{{item.year}}</h3>
<ul class="year-wrapper">
<li v-for="(subItem, subIndex) in item.data" :key="subIndex">
<span class="date">{{dateFormat(new Date(subItem.frontmatter.date))}}</span>
<span class="date">{{dateFormat(subItem.frontmatter.date)}}</span>
<span class="title" @click="go(subItem.path)">{{subItem.title}}</span>
</li>
</ul>
@ -75,6 +75,8 @@ export default {
},
//
dateFormat (date, type) {
date = date.replace(/-/g,'/')
const dateObj = new Date(date)
const dateObj = new Date(date)
const year = dateObj.getFullYear()
const mon = dateObj.getMonth() + 1