2016-07-27 14:15:02 +08:00
|
|
|
|
<style>
|
|
|
|
|
.el-loading-demo {
|
|
|
|
|
border: solid 1px #999;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
text-align: center;
|
2016-08-25 18:24:51 +08:00
|
|
|
|
margin-top: 10px;
|
2016-08-19 14:45:08 +08:00
|
|
|
|
|
2016-07-27 14:15:02 +08:00
|
|
|
|
p {
|
|
|
|
|
font-size: 30px;
|
|
|
|
|
color: #999;
|
|
|
|
|
margin: 10px 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
loading: false,
|
|
|
|
|
loading2: false,
|
|
|
|
|
fullscreenLoading: false,
|
|
|
|
|
tableLoading: false,
|
|
|
|
|
tableData: [{
|
|
|
|
|
date: '2016-05-02',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1518 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-04',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1517 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-01',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1519 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1516 弄'
|
|
|
|
|
}, {
|
|
|
|
|
date: '2016-05-03',
|
|
|
|
|
name: '王小虎',
|
|
|
|
|
address: '上海市普陀区金沙江路 1516 弄'
|
|
|
|
|
}]
|
|
|
|
|
}
|
|
|
|
|
},
|
2016-08-19 14:45:08 +08:00
|
|
|
|
|
2016-07-27 14:15:02 +08:00
|
|
|
|
methods: {
|
|
|
|
|
loadTable() {
|
|
|
|
|
this.tableLoading = true;
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.tableLoading = false;
|
|
|
|
|
}, 2000);
|
|
|
|
|
},
|
2016-08-19 14:45:08 +08:00
|
|
|
|
|
2016-07-27 14:15:02 +08:00
|
|
|
|
openFullScreen() {
|
|
|
|
|
this.fullscreenLoading = true;
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.fullscreenLoading = false;
|
|
|
|
|
}, 2000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
## 基本用法
|
|
|
|
|
|
2016-08-25 18:24:51 +08:00
|
|
|
|
:::demo 在 Loading 组件中,Element 准备了自定义命令`v-loading`,只需要绑定`Boolean`即可,默认状况下,Loading 遮罩会插入到绑定元素的子节点。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
|
|
|
|
```html
|
2016-08-19 14:45:08 +08:00
|
|
|
|
<el-button :plain="true" @click.native="loading = !loading">打开 / 关闭 loading</el-button>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
|
|
|
|
<div v-loading="loading" class="el-loading-demo">
|
|
|
|
|
<p>点击上面的按钮,本区域显示 loading 遮罩</p>
|
|
|
|
|
</div>
|
|
|
|
|
```
|
2016-08-25 18:24:51 +08:00
|
|
|
|
:::
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
|
|
|
|
## 修饰符
|
|
|
|
|
|
2016-08-25 18:24:51 +08:00
|
|
|
|
通过修饰符,我们可以使用全屏幕 Loading 或将 Loading 设置在 body 上。
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
2016-08-25 18:24:51 +08:00
|
|
|
|
:::demo Loading 遮罩默认插入至绑定了 `v-loading` 指令的元素上。通过添加 `body` 修饰符,可以使遮罩插入至 DOM 中的 body 上。当需要全屏遮罩时,可使用 `fullscreen` 修饰符(此时遮罩会插入至 body 上)
|
2016-07-27 14:15:02 +08:00
|
|
|
|
|
|
|
|
|
```html
|
|
|
|
|
<template>
|
2016-08-25 18:24:51 +08:00
|
|
|
|
<el-button :plain="true" @click.native="loading2 = !loading2">打开 / 关闭 loading</el-button>
|
|
|
|
|
|
2016-07-27 14:15:02 +08:00
|
|
|
|
<el-button
|
|
|
|
|
:plain="true"
|
2016-08-19 14:45:08 +08:00
|
|
|
|
@click.native="openFullScreen"
|
2016-07-27 14:15:02 +08:00
|
|
|
|
v-loading.fullscreen="fullscreenLoading">
|
|
|
|
|
打开全屏 loading
|
|
|
|
|
</el-button>
|
2016-08-25 18:24:51 +08:00
|
|
|
|
|
|
|
|
|
<div v-loading.body="loading2" class="el-loading-demo">
|
|
|
|
|
<p>点击上面的按钮,本区域显示 loading 遮罩</p>
|
|
|
|
|
</div>
|
2016-07-27 14:15:02 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
fullscreenLoading: false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
methods: {
|
|
|
|
|
openFullScreen() {
|
|
|
|
|
this.fullscreenLoading = true;
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.fullscreenLoading = false;
|
|
|
|
|
}, 2000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2016-08-19 14:45:08 +08:00
|
|
|
|
```
|
2016-08-25 18:24:51 +08:00
|
|
|
|
:::
|