index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div class="small-components-container">
  3. <el-row :gutter="20">
  4. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  5. <el-divider content-position="left">小组件</el-divider>
  6. </el-col>
  7. <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8">
  8. <el-card shadow="hover">
  9. <div slot="header">
  10. <span>snow</span>
  11. </div>
  12. <vab-snow></vab-snow>
  13. </el-card>
  14. </el-col>
  15. <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8">
  16. <el-card shadow="hover">
  17. <div slot="header">
  18. <span>profile</span>
  19. <el-button
  20. style="float: right; padding: 3px 0"
  21. type="text"
  22. @click="handleProfile"
  23. >
  24. 重载
  25. </el-button>
  26. </div>
  27. <vab-profile
  28. v-if="profileShow"
  29. avatar="https://picsum.photos/80/80?random=2"
  30. user-name="chuzhixin"
  31. ></vab-profile>
  32. </el-card>
  33. </el-col>
  34. <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8">
  35. <el-card shadow="hover">
  36. <div slot="header">
  37. <span>charge</span>
  38. </div>
  39. <vab-charge :start-val="startVal" :end-val="endVal"></vab-charge>
  40. </el-card>
  41. </el-col>
  42. </el-row>
  43. </div>
  44. </template>
  45. <script>
  46. import VabSnow from "@/components/VabSnow";
  47. import VabProfile from "@/components/VabProfile";
  48. import VabCharge from "@/components/VabCharge";
  49. export default {
  50. name: "Sticky",
  51. components: {
  52. VabSnow,
  53. VabProfile,
  54. VabCharge,
  55. },
  56. data() {
  57. return {
  58. profileShow: true,
  59. faultTextShow: true,
  60. solidTextShow: true,
  61. startVal: 0,
  62. endVal: 20,
  63. timeInterval: null,
  64. };
  65. },
  66. mounted() {
  67. this.handleProfile();
  68. this.handleSolidText();
  69. this.timeInterval = setInterval(() => {
  70. if (this.endVal < 100) {
  71. this.startVal = this.endVal;
  72. this.endVal++;
  73. }
  74. }, 5000);
  75. },
  76. beforeDestroy() {
  77. if (this.clearInterval) {
  78. clearInterval(this.timeInterval);
  79. }
  80. },
  81. methods: {
  82. handleProfile() {
  83. this.profileShow = false;
  84. setTimeout(() => {
  85. this.profileShow = true;
  86. });
  87. },
  88. handleSolidText() {
  89. this.solidTextShow = false;
  90. setTimeout(() => {
  91. this.solidTextShow = true;
  92. });
  93. },
  94. },
  95. };
  96. </script>
  97. <style lang="scss" scoped>
  98. .small-components-container {
  99. ::v-deep {
  100. .el-card__body {
  101. display: flex;
  102. align-items: center; /* 垂直居中 */
  103. justify-content: center; /* 水平居中 */
  104. height: 430px;
  105. }
  106. }
  107. }
  108. </style>