element/examples/docs/loading.md

91 lines
1.7 KiB
Markdown
Raw Normal View History

2016-07-27 14:15:02 +08:00
<style>
.el-loading-demo {
border: solid 1px #999;
2016-08-29 19:01:42 +08:00
border-radius: 4px;
height: 100px;
2016-07-27 14:15:02 +08:00
}
</style>
<script>
export default {
data() {
return {
2016-08-29 19:01:42 +08:00
loading: true,
2016-07-27 14:15:02 +08:00
loading2: false,
2016-08-29 19:01:42 +08:00
fullscreenLoading: false
2016-07-27 14:15:02 +08:00
}
},
2016-08-19 14:45:08 +08:00
2016-07-27 14:15:02 +08:00
methods: {
openFullScreen() {
this.fullscreenLoading = true;
setTimeout(() => {
this.fullscreenLoading = false;
2016-08-29 19:01:42 +08:00
}, 3000);
2016-07-27 14:15:02 +08:00
}
}
}
</script>
## Loading 加载
2016-08-29 19:01:42 +08:00
2016-09-07 18:46:20 +08:00
加载数据时显示动效。
2016-07-27 14:15:02 +08:00
2016-08-29 19:01:42 +08:00
### 区域加载
2016-09-07 18:46:20 +08:00
在表格等容器中加载数据时显示。
2016-07-27 14:15:02 +08:00
2016-09-07 18:46:20 +08:00
:::demo 在 Loading 组件中Element 准备了自定义命令`v-loading`,只需要绑定`Boolean`即可。默认状况下Loading 遮罩会插入到绑定元素的子节点,通过添加`body`修饰符,可以使遮罩插入至 DOM 中的 body 上。
2016-07-27 14:15:02 +08:00
```html
2016-08-29 19:01:42 +08:00
<template>
<div v-loading="loading" class="el-loading-demo"></div>
</template>
2016-07-27 14:15:02 +08:00
2016-08-29 19:01:42 +08:00
<script>
export default {
data() {
return {
loading: true
};
}
};
</script>
2016-07-27 14:15:02 +08:00
```
:::
2016-07-27 14:15:02 +08:00
2016-08-29 19:01:42 +08:00
### 整页加载
2016-07-27 14:15:02 +08:00
2016-09-07 18:46:20 +08:00
页面数据加载时显示。
2016-07-27 14:15:02 +08:00
2016-09-07 18:46:20 +08:00
:::demo 当需要全屏遮罩时,可使用`fullscreen`修饰符(此时遮罩会插入至 body 上)
2016-07-27 14:15:02 +08:00
```html
<template>
<el-button
2016-08-29 19:01:42 +08:00
type="primary"
2016-08-19 14:45:08 +08:00
@click.native="openFullScreen"
2016-07-27 14:15:02 +08:00
v-loading.fullscreen="fullscreenLoading">
2016-08-29 19:01:42 +08:00
显示整页加载3 秒后消失
2016-07-27 14:15:02 +08:00
</el-button>
</template>
<script>
export default {
data() {
return {
fullscreenLoading: false
}
}
methods: {
openFullScreen() {
this.fullscreenLoading = true;
setTimeout(() => {
this.fullscreenLoading = false;
2016-08-29 19:01:42 +08:00
}, 3000);
2016-07-27 14:15:02 +08:00
}
}
}
</script>
2016-08-19 14:45:08 +08:00
```
:::