rendering-with-data.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <el-space direction="vertical" alignment="flex-start">
  3. <el-button @click="setLoading">Click me to reload</el-button>
  4. <el-skeleton style="width: 240px" :loading="loading" animated :count="3">
  5. <template #template>
  6. <el-skeleton-item variant="image" style="width: 400px; height: 267px" />
  7. <div style="padding: 14px">
  8. <el-skeleton-item variant="h3" style="width: 50%" />
  9. <div
  10. style="
  11. display: flex;
  12. align-items: center;
  13. justify-items: space-between;
  14. margin-top: 16px;
  15. height: 16px;
  16. "
  17. >
  18. <el-skeleton-item variant="text" style="margin-right: 16px" />
  19. <el-skeleton-item variant="text" style="width: 30%" />
  20. </div>
  21. </div>
  22. </template>
  23. <template #default>
  24. <el-card
  25. v-for="item in lists"
  26. :key="item.name"
  27. :body-style="{ padding: '0px', marginBottom: '1px' }"
  28. >
  29. <img :src="item.imgUrl" class="image multi-content" />
  30. <div style="padding: 14px">
  31. <span>{{ item.name }}</span>
  32. <div class="bottom card-header">
  33. <div class="time">{{ currentDate }}</div>
  34. <el-button text class="button">Operation button</el-button>
  35. </div>
  36. </div>
  37. </el-card>
  38. </template>
  39. </el-skeleton>
  40. </el-space>
  41. </template>
  42. <script lang="ts" setup>
  43. import { onMounted, ref } from 'vue'
  44. interface ListItem {
  45. imgUrl: string
  46. name: string
  47. }
  48. const loading = ref(true)
  49. const lists = ref<ListItem[]>([])
  50. const currentDate = new Date().toDateString()
  51. const setLoading = () => {
  52. loading.value = true
  53. setTimeout(() => {
  54. loading.value = false
  55. }, 2000)
  56. }
  57. onMounted(() => {
  58. loading.value = false
  59. lists.value = [
  60. {
  61. imgUrl:
  62. 'https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg',
  63. name: 'Deer',
  64. },
  65. {
  66. imgUrl:
  67. 'https://fuss10.elemecdn.com/1/34/19aa98b1fcb2781c4fba33d850549jpeg.jpeg',
  68. name: 'Horse',
  69. },
  70. {
  71. imgUrl:
  72. 'https://fuss10.elemecdn.com/0/6f/e35ff375812e6b0020b6b4e8f9583jpeg.jpeg',
  73. name: 'Mountain Lion',
  74. },
  75. ]
  76. })
  77. </script>