# Loading加载中

用于页面和区块的加载中状态。

## 何时使用

页面局部处于等待异步数据或正在渲染过程时，合适的加载动效会有效缓解用户的焦虑。

### 区域加载
    
::: demo 在各种容器中加载数据时显示。对于自定义指令v-loading，只需要绑定Boolean即可。默认状况下，Loading 遮罩会插入到绑定元素的子节点，通过添加body修饰符，可以使遮罩插入至 DOM 中的 body 上。
```html
<template>
    <ut-card v-loading='true' style='height:200px'>
        <ut-button type='primary'>开始加载</ut-button>
    </ut-card>
</template>
```
:::

### 加载文案
    
::: demo  可自定义加载文案,在绑定了v-loading指令的元素上添加utear-loading-text属性，其值会被渲染为加载文案，并显示在加载图标的下方。
```html
<template>
    <ut-card v-loading='true' style='height:200px' utear-loading-text='loading...' >
        <ut-button type='primary'>开始加载</ut-button>
    </ut-card>
</template>
```
:::

### 整页加载

::: demo  当需要全屏遮罩时，可使用fullscreen修饰符（此时遮罩会插入至 body 上）。此时若需要锁定屏幕的滚动，可以使用lock修饰符。

```html
<template>
    <ut-button type='info' 
        utear-loading-text='loading...' 
        v-loading.fullscreen.lock='fullScreen' 
        @click.native='show'>显示整页加载，3 秒后消失</ut-button>
</template>
<script>
    export default {
        data(){
            return {
                fullScreen:false
            }
        },
        methods:{
            show(){
                this.fullScreen=true;
                setTimeout(()=>{
                    this.fullScreen=false;
                },3000)
            }
        }
    }
</script>
```
:::


### 多彩加载

::: demo  通过utear-loading-type 来控制颜色 多种状态色

```html
<template>
    <ut-card utear-loading-type='success' utear-loading-text='loading...' v-loading='true'  style='height:200px'>
        <ut-button type='success' @click.native='show'>绿色加载</ut-button>
    </ut-card>
</template>
<script>
    export default {
        data(){
            return {
                fullScreen:false
            }
        },
        methods:{
            show(){
                this.fullScreen=true;
                setTimeout(()=>{
                    this.fullScreen=false;
                },3000)
            }
        }
    }
</script>
```
:::


<script>
    export default {
        data(){
            return {
                fullScreen:false
            }
        },
        methods:{
            show(){
                this.fullScreen=true;
                setTimeout(()=>{
                    this.fullScreen=false;
                },3000)
            }
        }
    }
</script>