引入

  1. {
  2. "usingComponents": {
  3. "x-loading":"waft-ui/assembly/loading/loading"
  4. }
  5. }

代码示例

  1. <x-loading text="加载中" loading="{{ loading3 }}" vertical="{{ true }}" size="{{ 80 }}" full="{{ true }}"></x-loading>

效果展示

loading.png

组件样式

html

  1. <view class="loading">
  2. <x-nav-bar showArrow="{{true}}" title="测试 loading 组件"></x-nav-bar>
  3. <view class="content">
  4. <view class="title">水平 loading</view>
  5. <view style="height: 150rpx;width: 50vw;border:1rpx solid red">
  6. <x-loading text="加载中" loading="{{ loading1 }}"></x-loading>
  7. </view>
  8. <view class="title">垂直 loading</view>
  9. <view style="height: 150rpx;width: 50vw;border:1rpx solid red">
  10. <x-loading text="加载中" loading="{{ loading2 }}" vertical="{{ true }}" size="{{ 60 }}"></x-loading>
  11. </view>
  12. <view class="btn" onTap="onLoading">点击开启全屏 loading</view>
  13. <x-loading text="加载中" loading="{{ loading3 }}" vertical="{{ true }}" size="{{ 80 }}" full="{{ true }}"></x-loading>
  14. </view>
  15. </view>

TS

import { Props, Page, Event, console } from 'waft';
import { JSONObject } from 'waft-json';


export class TestLoading extends Page {
  loading: boolean = false;
  constructor(props: Props) {
    super(props);
  }

  onLoading(e: Event): void{
    const state = new JSONObject();
    this.loading = !this.loading;
    state.set('loading3', this.loading);
    console.log('====#### 即将改变 loading 状态 = ' + state.toString());
    this.setState(state);
  }
}

css

.title {
    font-size: 20rpx;
    color: #2b3852;
    margin-bottom: 10rpx;
}
.btn {
    padding: 10rpx 20rpx;
    border-radius: 6rpx;
    background-color: #00b3ff;
    color: #E6F2FF;
    margin-top: 40rpx;
}

.loading{
    width: 100%;
    height: 100%;
    display: flex;
    justify-content:flex-start;
    align-items: center;
    flex-direction: column;
    background-color: #F0F2F7;
}
.content{
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content:flex-start;
    align-items: center;
}

API

  • props | 参数 | 说明 | 类型 | 默认值 | | —- | —- | —- | —- | | loading | 是否 loading 状态 | boolean | false | | full | 是否全屏 loading | boolean | false | | size | loading 图标大小 | number | 30 | | text | loading 文字 | string | | | textSize | loading 文字大小 | number | 22 | | textColor | loading 文字颜色 | string | #7383a2 | | vertical | 是否垂直排列文案 | boolean | false |