fix(carousel): doesn't work with v-for children

This commit is contained in:
07akioni 2021-07-04 20:16:33 +08:00
parent 8579578e6b
commit 58897a73bf
3 changed files with 6 additions and 2 deletions

View File

@ -13,6 +13,7 @@
- Fix `n-upload` `multiple=false` doesn't work for drag & drop, closes [#363](https://github.com/TuSimple/naive-ui/issues/363).
- Fix `n-dropdown`'s inner `<a />`'s style.
- Fix `n-menu` tooltip's inner `<a />`'s style, closes [#338](https://github.com/TuSimple/naive-ui/issues/338).
- Fix `n-carousel` doesn't work with `v-for` children.
## 2.15.2 (2021-07-02)

View File

@ -13,6 +13,7 @@
- 修复 `n-upload` `multiple=false` 对于拖拽不生效,关闭 [#363](https://github.com/TuSimple/naive-ui/issues/363)
- 修复 `n-dropdown``<a />` 的样式
- 修复 `n-menu` tooltip 中 `<a />` 的样式,关闭 [#338](https://github.com/TuSimple/naive-ui/issues/338)
- 修复 `n-carousel` 无法使用 `v-for` 的子元素
## 2.15.2 (2021-07-02)

View File

@ -15,7 +15,8 @@ import { indexMap } from 'seemly'
import { on, off } from 'evtd'
import { useConfig, useTheme } from '../../_mixins'
import type { ThemeProps } from '../../_mixins'
import { ExtractPublicPropTypes } from '../../_utils'
import { flatten } from '../../_utils'
import type { ExtractPublicPropTypes } from '../../_utils'
import { carouselLight } from '../styles'
import type { CarouselTheme } from '../styles'
import style from './styles/index.cssr'
@ -235,7 +236,8 @@ export default defineComponent({
lengthRef,
$slots: { default: defaultSlot }
} = this
const children = defaultSlot?.().filter((v) => v) || []
const children = flatten(defaultSlot?.() || [])
console.log(children)
const { length } = children
lengthRef.value = length
const leftOverflowVNode = length ? cloneVNode(children[length - 1]) : null