Skip to content

Commit b8e507d

Browse files
author
huangshuwei
committed
add loading example
1 parent 35c1d25 commit b8e507d

File tree

8 files changed

+229
-3
lines changed

8 files changed

+229
-3
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
:::anchor Usage
2+
3+
More about Loading, Please refer to [Loading component](#/en/doc/base/loading)
4+
5+
:::demo
6+
7+
```html
8+
<template>
9+
<div>
10+
<button class="button-demo" @click="show()">Open</button>
11+
<button class="button-demo" @click="close()">Close</button><br /><br />
12+
<ve-table id="loading-container" :columns="columns" :table-data="tableData" />
13+
</div>
14+
</template>
15+
<script>
16+
export default {
17+
data() {
18+
return {
19+
loadingInstance: null,
20+
columns: [
21+
{ field: "name", key: "a", title: "Name", align: "center" },
22+
{ field: "date", key: "b", title: "Date", align: "left" },
23+
{ field: "hobby", key: "c", title: "Hobby", align: "right" },
24+
{ field: "address", key: "d", title: "Address" },
25+
],
26+
tableData: [
27+
{
28+
name: "John",
29+
date: "1900-05-20",
30+
hobby: "coding and coding repeat",
31+
address: "No.1 Century Avenue, Shanghai",
32+
},
33+
{
34+
name: "Dickerson",
35+
date: "1910-06-20",
36+
hobby: "coding and coding repeat",
37+
address: "No.1 Century Avenue, Beijing",
38+
},
39+
{
40+
name: "Larsen",
41+
date: "2000-07-20",
42+
hobby: "coding and coding repeat",
43+
address: "No.1 Century Avenue, Chongqing",
44+
},
45+
{
46+
name: "Geneva",
47+
date: "2010-08-20",
48+
hobby: "coding and coding repeat",
49+
address: "No.1 Century Avenue, Xiamen",
50+
},
51+
{
52+
name: "Jami",
53+
date: "2020-09-20",
54+
hobby: "coding and coding repeat",
55+
address: "No.1 Century Avenue, Shenzhen",
56+
},
57+
],
58+
};
59+
},
60+
methods: {
61+
show() {
62+
this.loadingInstance.show();
63+
},
64+
close() {
65+
this.loadingInstance.close();
66+
},
67+
},
68+
mounted() {
69+
this.loadingInstance = this.$veLoading({
70+
target: document.querySelector("#loading-container"),
71+
// 等同于
72+
// target:"#loading-container"
73+
name: "wave",
74+
});
75+
this.show();
76+
},
77+
destroyed() {
78+
this.loadingInstance.destroy();
79+
},
80+
};
81+
</script>
82+
```
83+
84+
:::
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
:::tip
2+
It's very simple for the table component to start loading. You can start loading when you request data<br>
3+
4+
:::
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<div>
3+
<h2>Enable Loading</h2>
4+
<Explain />
5+
<basic />
6+
</div>
7+
</template>
8+
<script>
9+
import Explain from "./explain.md";
10+
import Basic from "./basic.md";
11+
12+
export default {
13+
name: "basic-main",
14+
components: {
15+
Explain,
16+
Basic
17+
}
18+
};
19+
</script>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
:::anchor 示例
2+
3+
更多 Loading 使用方法,请参考 [Loading 组件](#/zh/doc/base/loading)
4+
5+
:::demo
6+
7+
```html
8+
<template>
9+
<div>
10+
<button class="button-demo" @click="show()">开启 Loading</button>
11+
<button class="button-demo" @click="close()">关闭 Loading</button><br /><br />
12+
<ve-table id="loading-container" :columns="columns" :table-data="tableData" />
13+
</div>
14+
</template>
15+
<script>
16+
export default {
17+
data() {
18+
return {
19+
loadingInstance: null,
20+
columns: [
21+
{ field: "name", key: "a", title: "Name", align: "center" },
22+
{ field: "date", key: "b", title: "Date", align: "left" },
23+
{ field: "hobby", key: "c", title: "Hobby", align: "right" },
24+
{ field: "address", key: "d", title: "Address" },
25+
],
26+
tableData: [
27+
{
28+
name: "John",
29+
date: "1900-05-20",
30+
hobby: "coding and coding repeat",
31+
address: "No.1 Century Avenue, Shanghai",
32+
},
33+
{
34+
name: "Dickerson",
35+
date: "1910-06-20",
36+
hobby: "coding and coding repeat",
37+
address: "No.1 Century Avenue, Beijing",
38+
},
39+
{
40+
name: "Larsen",
41+
date: "2000-07-20",
42+
hobby: "coding and coding repeat",
43+
address: "No.1 Century Avenue, Chongqing",
44+
},
45+
{
46+
name: "Geneva",
47+
date: "2010-08-20",
48+
hobby: "coding and coding repeat",
49+
address: "No.1 Century Avenue, Xiamen",
50+
},
51+
{
52+
name: "Jami",
53+
date: "2020-09-20",
54+
hobby: "coding and coding repeat",
55+
address: "No.1 Century Avenue, Shenzhen",
56+
},
57+
],
58+
};
59+
},
60+
methods: {
61+
show() {
62+
this.loadingInstance.show();
63+
},
64+
close() {
65+
this.loadingInstance.close();
66+
},
67+
},
68+
mounted() {
69+
this.loadingInstance = this.$veLoading({
70+
target: document.querySelector("#loading-container"),
71+
// 等同于
72+
// target:"#loading-container"
73+
name: "wave",
74+
});
75+
this.show();
76+
},
77+
destroyed() {
78+
this.loadingInstance.destroy();
79+
},
80+
};
81+
</script>
82+
```
83+
84+
:::
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
:::tip
2+
1、Table 组件开启 Loading 效果是非常简单的,请求数据时开启 Loading 即可<br>
3+
4+
:::
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<div>
3+
<h2>结合 Loading 组件</h2>
4+
<Explain />
5+
<basic />
6+
</div>
7+
</template>
8+
<script>
9+
import Explain from "./explain.md";
10+
import Basic from "./basic.md";
11+
12+
export default {
13+
name: "basic-main",
14+
components: {
15+
Explain,
16+
Basic
17+
}
18+
};
19+
</script>

examples/src/router/locale/en.router.config.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ const config = [
232232
name: "Pagination",
233233
meta: { keepAlive: true }
234234
},
235+
{
236+
path: "loading",
237+
component: () => import("@/docs/en/ve-table/loading/main.vue"),
238+
name: "Enable Loading",
239+
meta: { keepAlive: true }
240+
},
235241
{
236242
path: "virtual-scroll",
237243
component: () =>
@@ -253,8 +259,8 @@ const config = [
253259
meta: { keepAlive: true }
254260
}
255261
]
256-
},
257-
/* {
262+
}
263+
/* {
258264
path: "other",
259265
name: "辅助组件",
260266
component: emptyLayout,

examples/src/router/locale/zh.router.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ const config = [
224224
name: "分页",
225225
meta: { keepAlive: true }
226226
},
227+
{
228+
path: "loading",
229+
component: () => import("@/docs/zh/ve-table/loading/main.vue"),
230+
name: "开启 loading",
231+
meta: { keepAlive: true }
232+
},
227233
{
228234
path: "virtual-scroll",
229235
component: () =>
@@ -245,7 +251,7 @@ const config = [
245251
meta: { keepAlive: true }
246252
}
247253
]
248-
},
254+
}
249255
/* {
250256
path: "other",
251257
name: "辅助组件",

0 commit comments

Comments
 (0)