mirror of https://github.com/ElemeFE/element
183 lines
3.9 KiB
Markdown
183 lines
3.9 KiB
Markdown
![]() |
<script>
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
tableData: [{
|
||
|
date: '2016-05-02',
|
||
|
name: 'John Smith',
|
||
|
address: 'No.1518, Jinshajiang Road, Putuo District'
|
||
|
}, {
|
||
|
date: '2016-05-04',
|
||
|
name: 'John Smith',
|
||
|
address: 'No.1518, Jinshajiang Road, Putuo District'
|
||
|
}, {
|
||
|
date: '2016-05-01',
|
||
|
name: 'John Smith',
|
||
|
address: 'No.1518, Jinshajiang Road, Putuo District'
|
||
|
}],
|
||
|
loading: true,
|
||
|
loading2: true,
|
||
|
fullscreenLoading: false
|
||
|
}
|
||
|
},
|
||
|
|
||
|
methods: {
|
||
|
openFullScreen() {
|
||
|
this.fullscreenLoading = true;
|
||
|
setTimeout(() => {
|
||
|
this.fullscreenLoading = false;
|
||
|
}, 3000);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
## Loading
|
||
|
|
||
|
Show animation while loading data.
|
||
|
|
||
|
### Loading inside a container
|
||
|
|
||
|
Displays animation in a container (such as a table) while loading data.
|
||
|
|
||
|
:::demo We provide a custom directive `v-loading`. You just need to bind a `boolean` value to it. By default, the loading mask will append to the element where the directive is used. Adding the `body` modifier makes the mask append to the body element.
|
||
|
|
||
|
```html
|
||
|
<template>
|
||
|
<el-table
|
||
|
v-loading.body="loading"
|
||
|
:data="tableData"
|
||
|
style="width: 100%">
|
||
|
<el-table-column
|
||
|
prop="date"
|
||
|
label="Date"
|
||
|
width="180">
|
||
|
</el-table-column>
|
||
|
<el-table-column
|
||
|
prop="name"
|
||
|
label="Name"
|
||
|
width="180">
|
||
|
</el-table-column>
|
||
|
<el-table-column
|
||
|
prop="address"
|
||
|
label="Address">
|
||
|
</el-table-column>
|
||
|
</el-table>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
tableData: [{
|
||
|
date: '2016-05-02',
|
||
|
name: 'John Smith',
|
||
|
address: 'No.1518, Jinshajiang Road, Putuo District'
|
||
|
}, {
|
||
|
date: '2016-05-04',
|
||
|
name: 'John Smith',
|
||
|
address: 'No.1518, Jinshajiang Road, Putuo District'
|
||
|
}, {
|
||
|
date: '2016-05-01',
|
||
|
name: 'John Smith',
|
||
|
address: 'No.1518, Jinshajiang Road, Putuo District'
|
||
|
}],
|
||
|
loading: true
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
</script>
|
||
|
```
|
||
|
:::
|
||
|
|
||
|
### Loading text
|
||
|
|
||
|
You can customize a text message.
|
||
|
|
||
|
:::demo
|
||
|
```html
|
||
|
<template>
|
||
|
<el-table
|
||
|
v-loading="loading2"
|
||
|
element-loading-text="Loading..."
|
||
|
:data="tableData"
|
||
|
style="width: 100%">
|
||
|
<el-table-column
|
||
|
prop="date"
|
||
|
label="Date"
|
||
|
width="180">
|
||
|
</el-table-column>
|
||
|
<el-table-column
|
||
|
prop="name"
|
||
|
label="Name"
|
||
|
width="180">
|
||
|
</el-table-column>
|
||
|
<el-table-column
|
||
|
prop="address"
|
||
|
label="Address">
|
||
|
</el-table-column>
|
||
|
</el-table>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
tableData: [{
|
||
|
date: '2016-05-02',
|
||
|
name: 'John Smith',
|
||
|
address: 'No.1518, Jinshajiang Road, Putuo District'
|
||
|
}, {
|
||
|
date: '2016-05-04',
|
||
|
name: 'John Smith',
|
||
|
address: 'No.1518, Jinshajiang Road, Putuo District'
|
||
|
}, {
|
||
|
date: '2016-05-01',
|
||
|
name: 'John Smith',
|
||
|
address: 'No.1518, Jinshajiang Road, Putuo District'
|
||
|
}],
|
||
|
loading2: true
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
</script>
|
||
|
```
|
||
|
:::
|
||
|
|
||
|
### Full screen loading
|
||
|
|
||
|
Show a full screen animation while loading data.
|
||
|
|
||
|
:::demo Add the `fullscreen` modifier to create a full screen mask, and it will append to body. In this case, if you disable scrolling on body, you add another modifier `lock`.
|
||
|
|
||
|
```html
|
||
|
<template>
|
||
|
<el-button
|
||
|
type="primary"
|
||
|
@click.native="openFullScreen"
|
||
|
v-loading.fullscreen.lock="fullscreenLoading">
|
||
|
Full screen loading for 3 seconds
|
||
|
</el-button>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
fullscreenLoading: false
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
openFullScreen() {
|
||
|
this.fullscreenLoading = true;
|
||
|
setTimeout(() => {
|
||
|
this.fullscreenLoading = false;
|
||
|
}, 3000);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
```
|
||
|
:::
|
||
|
|