未验证 提交 c51c279c 编写于 作者: Q QiuShuiBai 提交者: GitHub

fix(time-picker): should only display now on the current date (#750)

fix the bug that now is only displayed on the first date, let now be displayed on the current date
上级 919dabd8
...@@ -229,12 +229,21 @@ ...@@ -229,12 +229,21 @@
day.children = partHours day.children = partHours
}) })
if (this.showNow) { const dayDiff = getDayDiff(this.minTime, this.now)
days[0].children.unshift({
value: NOW.value, if (this.showNow && dayDiff <= 0) {
text: this.nowText, const index = Math.abs(dayDiff)
children: [] const daysData = days[index]
}) // Make sure 'now' is between the 'min' and 'max'
if (daysData) {
// Because daysData.children is a reference to this.hours, avoid destroying this.hourse by using spread operator '...'
daysData.children = [...daysData.children]
daysData.children.unshift({
value: NOW.value,
text: this.nowText,
children: []
})
}
} }
return days return days
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册