Ben Lin
2024-06-18 ebbd788fbb2c0b45d4473798efc57eec8ba74a25
src/views/demo/comp/scroll/Action.vue
@@ -19,36 +19,27 @@
    </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 {