From 6799189f579fd8f2b1a0a263b4a30b6fd6bf7fab Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 14 Oct 2021 19:00:39 +0800 Subject: [PATCH] chore: improve compiled jsx code of default slot (#9676) * chore: improve compiled jsx code of default slot * fix: teleport not support v-slots --- packages/vant/src/action-bar-icon/ActionBarIcon.tsx | 9 ++++++--- packages/vant/src/calendar/Calendar.tsx | 5 ++--- packages/vant/src/grid-item/GridItem.tsx | 8 +++++--- packages/vant/src/overlay/Overlay.tsx | 4 +--- packages/vant/src/popup/Popup.tsx | 5 ++--- packages/vant/src/pull-refresh/PullRefresh.tsx | 7 ++++++- packages/vant/src/tabbar-item/TabbarItem.tsx | 9 ++++++--- packages/vant/src/uploader/UploaderPreviewItem.tsx | 5 ++--- 8 files changed, 30 insertions(+), 22 deletions(-) diff --git a/packages/vant/src/action-bar-icon/ActionBarIcon.tsx b/packages/vant/src/action-bar-icon/ActionBarIcon.tsx index 16dc8b0e4..198b4c818 100644 --- a/packages/vant/src/action-bar-icon/ActionBarIcon.tsx +++ b/packages/vant/src/action-bar-icon/ActionBarIcon.tsx @@ -35,9 +35,12 @@ export default defineComponent({ if (slots.icon) { return ( - - {slots.icon()} - + ); } diff --git a/packages/vant/src/calendar/Calendar.tsx b/packages/vant/src/calendar/Calendar.tsx index d437fd1cb..891522127 100644 --- a/packages/vant/src/calendar/Calendar.tsx +++ b/packages/vant/src/calendar/Calendar.tsx @@ -558,6 +558,7 @@ export default defineComponent({ if (props.poppable) { return ( - {renderCalendar()} - + /> ); } diff --git a/packages/vant/src/grid-item/GridItem.tsx b/packages/vant/src/grid-item/GridItem.tsx index 2238dfa3a..9e9af682b 100644 --- a/packages/vant/src/grid-item/GridItem.tsx +++ b/packages/vant/src/grid-item/GridItem.tsx @@ -80,9 +80,11 @@ export default defineComponent({ const renderIcon = () => { if (slots.icon) { return ( - - {slots.icon()} - + ); } diff --git a/packages/vant/src/overlay/Overlay.tsx b/packages/vant/src/overlay/Overlay.tsx index 6e4692300..90a0c38b4 100644 --- a/packages/vant/src/overlay/Overlay.tsx +++ b/packages/vant/src/overlay/Overlay.tsx @@ -56,9 +56,7 @@ export default defineComponent({ }); return () => ( - - {renderOverlay()} - + ); }, }); diff --git a/packages/vant/src/popup/Popup.tsx b/packages/vant/src/popup/Popup.tsx index 4e0aee540..51010ea33 100644 --- a/packages/vant/src/popup/Popup.tsx +++ b/packages/vant/src/popup/Popup.tsx @@ -201,13 +201,12 @@ export default defineComponent({ return ( - {renderPopup()} - + /> ); }; diff --git a/packages/vant/src/pull-refresh/PullRefresh.tsx b/packages/vant/src/pull-refresh/PullRefresh.tsx index 6f2bb9bc0..a463146d3 100644 --- a/packages/vant/src/pull-refresh/PullRefresh.tsx +++ b/packages/vant/src/pull-refresh/PullRefresh.tsx @@ -123,7 +123,12 @@ export default defineComponent({ nodes.push(
{getStatusText()}
); } if (status === 'loading') { - nodes.push({getStatusText()}); + nodes.push( + + ); } return nodes; diff --git a/packages/vant/src/tabbar-item/TabbarItem.tsx b/packages/vant/src/tabbar-item/TabbarItem.tsx index d2f3f75b9..5802741cd 100644 --- a/packages/vant/src/tabbar-item/TabbarItem.tsx +++ b/packages/vant/src/tabbar-item/TabbarItem.tsx @@ -83,9 +83,12 @@ export default defineComponent({ style={{ color }} onClick={onClick} > - - {renderIcon()} - +
{slots.default?.({ active: active.value })}
diff --git a/packages/vant/src/uploader/UploaderPreviewItem.tsx b/packages/vant/src/uploader/UploaderPreviewItem.tsx index b71b90b73..26801d22b 100644 --- a/packages/vant/src/uploader/UploaderPreviewItem.tsx +++ b/packages/vant/src/uploader/UploaderPreviewItem.tsx @@ -95,6 +95,7 @@ export default defineComponent({ if (isImageFile(item)) { return ( - {renderCover()} - + /> ); }