mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
fix(scrollbar): doesn't support scrollTo
, closes #1346
This commit is contained in:
parent
e3ef366a3a
commit
f471c9bd04
@ -6,6 +6,7 @@
|
||||
|
||||
- Fix `n-data-table` fixed style does not work in group header table,closes [#1341](https://github.com/TuSimple/naive-ui/issues/1341).
|
||||
- Fix `n-data-table` has duplicate right border when it has multiple level headers.
|
||||
- Fix `n-scrollbar` doesn't support `scrollTo`, closes [#1346](https://github.com/TuSimple/naive-ui/issues/1346).
|
||||
|
||||
### Feats
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
- 修复 `n-data-table` `fixed` 样式在表头分组不生效的问题,关闭 [#1341](https://github.com/TuSimple/naive-ui/issues/1341)
|
||||
- 修复 `n-data-table` 多级表头右侧边框重复
|
||||
- 修复 `n-scrollbar` 不支持 `scrollTo`,关闭 [#1346](https://github.com/TuSimple/naive-ui/issues/1346)
|
||||
|
||||
### Feats
|
||||
|
||||
|
@ -22,3 +22,9 @@ x
|
||||
| Name | Parameters | Description |
|
||||
| ------- | ---------- | --------------- |
|
||||
| default | `()` | Scroll content. |
|
||||
|
||||
### Scrollbar Methods
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| scrollTo | `(options: { left?: number, top?: number, behavior?: ScrollBehavior }): void & (x: number, y: number) => void` | Scrolling content. |
|
||||
|
@ -22,3 +22,9 @@ x
|
||||
| 名称 | 参数 | 说明 |
|
||||
| ------- | ---- | -------- |
|
||||
| default | `()` | 滚动内容 |
|
||||
|
||||
### Scrollbar Methods
|
||||
|
||||
| 名称 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| scrollTo | `(options: { left?: number, top?: number, behavior?: ScrollBehavior }): void & (x: number, y: number) => void` | 滚动内容 |
|
||||
|
@ -1,10 +1,13 @@
|
||||
import { h, defineComponent, PropType } from 'vue'
|
||||
import { h, defineComponent, PropType, ref } from 'vue'
|
||||
import { NScrollbar } from '../../_internal'
|
||||
import { ScrollbarTheme } from '../../_internal/scrollbar/styles'
|
||||
import { useTheme, ThemeProps } from '../../_mixins'
|
||||
import type { ExtractPublicPropTypes } from '../../_utils'
|
||||
|
||||
export type ScrollTo = (x: number, y: number) => void
|
||||
export interface ScrollTo {
|
||||
(x: number, y: number): void
|
||||
(options: { left?: number, top?: number, behavior?: ScrollBehavior }): void
|
||||
}
|
||||
|
||||
export interface ScrollbarInst {
|
||||
scrollTo: ScrollTo
|
||||
@ -21,8 +24,24 @@ export type ScrollbarProps = ExtractPublicPropTypes<typeof scrollbarProps>
|
||||
const Scrollbar = defineComponent({
|
||||
name: 'Scrollbar',
|
||||
props: scrollbarProps,
|
||||
setup (props, { slots }) {
|
||||
return () => h(NScrollbar, props, slots)
|
||||
setup () {
|
||||
const scrollbarInstRef = ref<ScrollbarInst | null>(null)
|
||||
const exposedMethods: ScrollbarInst = {
|
||||
scrollTo: (...args: any[]) => {
|
||||
scrollbarInstRef.value?.scrollTo(args[0], args[1])
|
||||
}
|
||||
}
|
||||
return {
|
||||
...exposedMethods,
|
||||
scrollbarInstRef
|
||||
}
|
||||
},
|
||||
render () {
|
||||
return (
|
||||
<NScrollbar ref="scrollbarInstRef" {...this.$props}>
|
||||
{this.$slots}
|
||||
</NScrollbar>
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user