Skip to content

Commit a44a7eb

Browse files
committed
fix: 修复当 change-year-fast 等于 true 时,切换日历报错invalid node 的问题
1 parent c69306e commit a44a7eb

File tree

3 files changed

+30
-38
lines changed

3 files changed

+30
-38
lines changed

Diff for: src/calendar/Calendar.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ export default defineComponent({
274274
} else {
275275
yearMonthType.value = 'date';
276276
}
277-
278277
emit('calendarTypeChange', yearMonthType.value);
279278
};
280279

Diff for: src/calendar/CalendarScrollContainer.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,8 @@ export default defineComponent({
128128
}
129129
};
130130

131-
const renderDateItem = () => {
132-
console.log('props.calendarData', props.calendarData);
133-
return props.calendarData.map((item, i) => (
131+
const renderDateItem = () =>
132+
props.calendarData.map((item, i) => (
134133
<li
135134
class="calendar_group_li"
136135
key={i}
@@ -147,10 +146,9 @@ export default defineComponent({
147146
}s`,
148147
}}
149148
>
150-
{slots.default ? slots.default(item) : ''}
149+
{slots.default?.(item)}
151150
</li>
152151
));
153-
};
154152

155153
const renderContainer = () => (
156154
<ul

Diff for: src/calendar/CalendarYearMonth.tsx

+27-32
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ export default defineComponent({
263263
() => props.type,
264264
(val) => {
265265
disabledScrollDirec.value = props.disabledScroll;
266-
if (val === 'month') {
266+
if (val === 'month' || val === 'date') {
267267
disabledScrollDirec.value = true;
268268
yearMonthShow.value = [
269269
language.value.MONTH,
@@ -278,9 +278,8 @@ export default defineComponent({
278278
}
279279
);
280280

281-
const renderYearMonthItem = (arr: (YearRangeType & number)[]) => {
282-
console.log('arr', arr);
283-
return arr.map((item, index) => (
281+
const renderYearMonthItem = (arr: (YearRangeType & number)[]) =>
282+
arr.map((item, index) => (
284283
<div
285284
class={`year-body-item ${
286285
isDisabled(item, index)
@@ -311,35 +310,31 @@ export default defineComponent({
311310
</p>
312311
</div>
313312
));
314-
};
315313

316-
const renderYearMonth = () => {
317-
console.log('props.type', props.type);
318-
return (
319-
<div
320-
class="year-body"
321-
style={{
322-
top: props.calendarTitleHeight + 'px',
323-
height: itemHeight.value * 4 + 'px',
324-
display: ['year', 'yearRange', 'month'].includes(props.type)
325-
? 'block'
326-
: 'none',
327-
}}
328-
>
329-
<CalendarScrollContainer
330-
calendarData={yearMonthShow.value}
331-
disabledScroll={disabledScrollDirec.value}
332-
onTouchstart={touchStart}
333-
onTouchmove={touchMove}
334-
onTouchend={touchEnd}
335-
onSlidechange={slideChange}
336-
v-slots={(data: (YearRangeType & number)[]) =>
337-
renderYearMonthItem(data)
338-
}
339-
/>
340-
</div>
341-
);
342-
};
314+
const renderYearMonth = () => (
315+
<div
316+
class="year-body"
317+
style={{
318+
top: props.calendarTitleHeight + 'px',
319+
height: itemHeight.value * 4 + 'px',
320+
display: ['year', 'yearRange', 'month'].includes(props.type)
321+
? 'block'
322+
: 'none',
323+
}}
324+
>
325+
<CalendarScrollContainer
326+
calendarData={yearMonthShow.value}
327+
disabledScroll={disabledScrollDirec.value}
328+
onTouchstart={touchStart}
329+
onTouchmove={touchMove}
330+
onTouchend={touchEnd}
331+
onSlidechange={slideChange}
332+
v-slots={(data: (YearRangeType & number)[]) =>
333+
renderYearMonthItem(data)
334+
}
335+
/>
336+
</div>
337+
);
343338

344339
return () => renderYearMonth();
345340
},

0 commit comments

Comments
 (0)