diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index 20117a3c8..2bdac78a9 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -23,6 +23,7 @@ - Remove `n-calendar`'s useless `console.log`. - Fix loading-bar disappears unexpectl, closes [#343](https://github.com/TuSimple/naive-ui/issues/343). - Fix `n-select` doesn't scroll to selected item when menu is opened, closes [#346](https://github.com/TuSimple/naive-ui/issues/346). +- Fix `n-tab-pane` throws error when using v-if. ## 2.15.1 (2021-06-30) diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index 67c44799d..ffa469d24 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -23,6 +23,7 @@ - 移除 `n-calendar` 无用的 console.log - 修复 loading-bar 自动消失,关闭 [#343](https://github.com/TuSimple/naive-ui/issues/343) - 修复 `n-select` 打开菜单时没有自动滚动到选中项,关闭 [#346](https://github.com/TuSimple/naive-ui/issues/346) +- 修复 `n-tab-pane` 在使用 v-if 时报错 ## 2.15.1 (2021-06-30) diff --git a/src/tabs/src/TabPane.tsx b/src/tabs/src/TabPane.tsx index a80faa0ef..e058953bd 100644 --- a/src/tabs/src/TabPane.tsx +++ b/src/tabs/src/TabPane.tsx @@ -38,6 +38,7 @@ export const tabPaneProps = { export type TabPaneProps = ExtractPublicPropTypes export default defineComponent({ + __TAB_PANE__: true, name: 'TabPane', alias: ['TabPanel'], props: tabPaneProps, diff --git a/src/tabs/src/Tabs.tsx b/src/tabs/src/Tabs.tsx index e34afd19f..4eadcd95f 100644 --- a/src/tabs/src/Tabs.tsx +++ b/src/tabs/src/Tabs.tsx @@ -378,7 +378,11 @@ export default defineComponent({ mergedSize, $slots: { default: defaultSlot, prefix: prefixSlot, suffix: suffixSlot } } = this - const children = defaultSlot ? flatten(defaultSlot()) : [] + const children = defaultSlot + ? flatten(defaultSlot()).filter((v) => { + return (v.type as any).__TAB_PANE__ === true + }) + : [] const prefix = prefixSlot ? prefixSlot() : null const suffix = suffixSlot ? suffixSlot() : null const isCard = type === 'card'