Skip to content

Commit

Permalink
fix(date-picker): add nullish coalescing
Browse files Browse the repository at this point in the history
  • Loading branch information
BeADre committed Nov 13, 2021
1 parent 5e25e7b commit 8644d88
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/varlet-ui/src/date-picker/DatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export default defineComponent({
if (range) return `${chooseRangeMonth.value[0]} ~ ${chooseRangeMonth.value[1]}`
const monthName = pack.value.datePickerMonthDict?.[chooseMonth.value.index].name
const monthName = pack.value.datePickerMonthDict?.[chooseMonth.value.index].name ?? ''
return multiple ? `${chooseMonths.value.length}${pack.value.datePickerSelected}` : monthName
})
Expand All @@ -166,9 +166,9 @@ export default defineComponent({
const weekIndex = dayjs(`${chooseYear.value}-${chooseMonth.value.index}-${chooseDay.value}`).day()
const week: WeekDict = WEEK_HEADER.find((value) => value.index === `${weekIndex}`) as WeekDict
const weekName = pack.value.datePickerWeekDict?.[week.index].name
const weekName = pack.value.datePickerWeekDict?.[week.index].name ?? ''
const monthName = pack.value.datePickerMonthDict?.[chooseMonth.value.index].name
const monthName = pack.value.datePickerMonthDict?.[chooseMonth.value.index].name ?? ''
const showDay = chooseDay.value.padStart(2, '0')
if (pack.value.lang === 'zh-CN') return `${chooseMonth.value.index}-${showDay} ${weekName.slice(0, 3)}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default defineComponent({
return WEEK_HEADER.slice(index).concat(WEEK_HEADER.slice(0, index))
})
const getDayAbbr = (key: Week): string => pack.value.datePickerWeekDict?.[key].abbr
const getDayAbbr = (key: Week): string => pack.value.datePickerWeekDict?.[key].abbr ?? ''
const filterDay = (day: number): number | string => (day > 0 ? day : '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default defineComponent({
const isCurrentYear: ComputedRef<boolean> = computed(() => props.preview.previewYear === currentYear)
const getMonthAbbr = (key: Month): string => pack.value.datePickerMonthDict?.[key].abbr
const getMonthAbbr = (key: Month): string => pack.value.datePickerMonthDict?.[key].abbr ?? ''
const inRange = (key: string): boolean => {
const {
Expand Down

0 comments on commit 8644d88

Please sign in to comment.