| | |
| | | </div> |
| | | </PageWrapper> |
| | | </template> |
| | | <script lang="ts"> |
| | | import { defineComponent, ref, unref } from 'vue'; |
| | | import { ScrollContainer, ScrollActionType } from '/@/components/Container/index'; |
| | | import { PageWrapper } from '/@/components/Page'; |
| | | <script lang="ts" setup> |
| | | import { ref, unref } from 'vue'; |
| | | import { ScrollContainer, ScrollActionType } from '@/components/Container'; |
| | | import { PageWrapper } from '@/components/Page'; |
| | | import { type Nullable } from '@vben/types'; |
| | | |
| | | export default defineComponent({ |
| | | components: { ScrollContainer, PageWrapper }, |
| | | setup() { |
| | | const scrollRef = ref<Nullable<ScrollActionType>>(null); |
| | | const getScroll = () => { |
| | | const scroll = unref(scrollRef); |
| | | if (!scroll) { |
| | | throw new Error('scroll is Null'); |
| | | } |
| | | return scroll; |
| | | }; |
| | | const scrollRef = ref<Nullable<ScrollActionType>>(null); |
| | | const getScroll = () => { |
| | | const scroll = unref(scrollRef); |
| | | if (!scroll) { |
| | | throw new Error('scroll is Null'); |
| | | } |
| | | return scroll; |
| | | }; |
| | | |
| | | function scrollTo(top: number) { |
| | | getScroll().scrollTo(top); |
| | | } |
| | | function scrollBottom() { |
| | | getScroll().scrollBottom(); |
| | | } |
| | | return { |
| | | scrollTo, |
| | | scrollRef, |
| | | scrollBottom, |
| | | }; |
| | | }, |
| | | }); |
| | | function scrollTo(top: number) { |
| | | getScroll().scrollTo(top); |
| | | } |
| | | function scrollBottom() { |
| | | getScroll().scrollBottom(); |
| | | } |
| | | </script> |
| | | <style lang="less" scoped> |
| | | .scroll-wrap { |