1.0.2 • Published 4 years ago

tlst-ui v1.0.2

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

tlst-ui

安装

可以使用下列命令安装这个包:

npm install tlst-ui

使用

script

import { tlstScroll } from 'tlst-ui';
components:{
    tlstScroll
},
methods: {
    onPullingDown(next){
        ...逻辑代码
        next && next();
    }
}

template

<tlstScroll @onPullingDown="onPullingDown">
    .....页面代码
</tlstScroll>
上拉加载更多是采用其他库

vue-infinite-loading

示例

2 个示例代码快速了解如何使用 Scroll 组件。

  • 1. 基本使用 - Default

       <template>
             <tlstScroll @onPullingDown="onPullingDown">
                   .....内容部分
             </tlstScroll>
       </template>
       <script>
          import { tlstScroll } from 'tlst-ui';
          export default {
             data(){
                return{
                }
             },
             components:{
                tlstScroll
             },
             methods: {
                onPullingDown(next){
                   setTimeout(()=>{
                         next && next();
                         this.$createToast({
                            time: 1500,
                            txt: '延时2秒结束下拉',
                            mask: true,
                         }).show();
                   },2000)
                }
             }
          }
       </script>
  • 2. 下拉刷新,上拉加载更多 - All

       <template>
          <tlstScroll @onPullingUp="onPullingUp" :isMore="true" @onPullingDown="onPullingDown">
             .....内容部分
          </tlstScroll>
       </template>
       <script>
          import { tlstScroll } from 'tlst-ui';
          export default {
             data(){
                return{
                   maxNum:3,
                   newNum:0,
                   isajax:false,
                   infinite:"",
                }
             },
             components:{
                tlstScroll
             },
             methods: {
                onPullingDown(next){
                   setTimeout(()=>{
                         next && next();
                         this.newNum = 0;
                         this.infinite.reset();//重置
                   },2000)
                },
                async onPullingUp(obj){
                      this.newNum++;
                      if(!this.infinite){
                         this.infinite = obj;
                      }
                      if(this.newNum>this.maxNum){
                         obj.complete();//全部完成
                         return;
                      }
                      if(this.isajax)return;
                      this.isajax = true;
                      await new Promise((resolve)=>{
                         setTimeout(()=>{
                            resolve(1)
                         },2000)
                      });
                      this.isajax = false;
                      obj && obj.loaded && obj.loaded(); //结束这次
                }
             }
          }
       </script>

Props 配置

参数说明类型可选值默认值
isScrollTop是否需要实时滚动高度booleantrue/falsefalse
isMore是否需要上拉加载更多booleantrue/falsefalse

插槽

名字说明作用域参数
default内容体-

事件

事件名说明参数
onPullingDown下拉刷新next 返回回调函数,调用即结束下拉刷新
onPullingUp上拉加载更多Object 返回一个对象 可以用变量保存起来 Object.loaded() 已完成本次上拉加载更多 Object.complete() 结束上拉加载更多 Object.reset() 重置上拉加载更多
1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago