Scroller

滚动组件。

使用方法

  • 事件脚本示例:
    // 在script标签中按需引入
    import { Scroller } from '@jecloud/ui';
    export default {
      components: { Scroller },
      setup() {
          const scrollRef = ref(null);
          const getScroll = () => {
          const scroll = unref(scrollRef);
          if (!scroll) {
              throw new Error('scroll is Null');
          }
      return scroll;
    };
    function scrollTo(top) {
      getScroll().scroll({ y: top }, 500);
      }
      onMounted(() => {
          scrollTo(100);
      });
      return { scrollTo, scrollRef };
      },
    };
    // 在vue的template标签中
    <Scroller ref="scrollRef">
       <ul>
           <template v-for="index in 100" :key="index">
               <li>
                   {{ index }}
               </li>
           </template>
       </ul>
    </Scroller>
最后编辑: 秦永莲  文档更新时间: 2024-07-26 14:15   作者:秦永莲