|
| 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 | +::: |
0 commit comments