fix(tab-pane): throws error when using v-if

This commit is contained in:
07akioni 2021-07-02 10:59:22 +08:00
parent 30d0299e0d
commit 49c3f587c5
4 changed files with 8 additions and 1 deletions

View File

@ -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)

View File

@ -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)

View File

@ -38,6 +38,7 @@ export const tabPaneProps = {
export type TabPaneProps = ExtractPublicPropTypes<typeof tabPaneProps>
export default defineComponent({
__TAB_PANE__: true,
name: 'TabPane',
alias: ['TabPanel'],
props: tabPaneProps,

View File

@ -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'